如何让两个或多个 React Native App 相互共享数据?

How to allow two or more react native apps to share data with each other?

我正在研究 POC,我想在同一设备上的两个或多个应用程序之间共享数据。我读过 Android 的共享首选项,但文章说应用程序只能读取它们存储的数据,或者它们可以将数据存储为全局数据,在这种情况下,OS 上的所有应用程序都可以读取存储的数据数据。同样,我正在考虑将钥匙串用于 iOS.

简而言之问题:我希望能够与设备上的其他应用共享一段数据。

除了共享首选项和钥匙串之外,还有其他方法可以实现吗?

此外,所有应用程序都将使用 React Native 编写。

我不知道您将如何在 iOS/ReactNative 中实现此功能,但在 Android 中,要在应用程序之间共享数据,您需要使用 ContentProvider

A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object. Together, providers and provider clients offer a consistent, standard interface to data that also handles inter-process communication and secure data access.

Typically you work with content providers in one of two scenarios; you may want to implement code to access an existing content provider in another application, or you may want to create a new content provider in your application to share data with other applications. This topic covers the basics of working with existing content providers. To learn more about implementing content providers in your own applications, see Creating a content provider.

您可能会找到更多信息here, and a very good example from here