Google 的 G Suite 应用程序如何共享数据?

How do Google's G Suite Apps share data?

似乎当您为 iOS 下载新的 Google Suite 应用程序时 - 无论是 GMail、收件箱、日历还是其他任何应用程序 - 他们都会让您使用您的帐户登录 并且已经向您展示了您在别处登录的帐户

这个问题既针对 iOS 也针对 Android。

我知道应用程序可以使用 Safari 或新的 Safari WebView(Chrome 选项卡 Android)和永久 cookie 在应用程序之间共享数据。它有点笨拙,并且可以通过用户删除 cookie 来破坏。但除此之外,它有效。

Google 好像用的是别的东西。广告ID?他们究竟如何实现在两个操作系统上共享数据的壮举?

上 Android:

他们可能使用 Content Providers. As described in this link,

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.

内容提供者协调对您应用程序中的数据存储层的访问,以获取许多不同的 API 和组件,其中包括:

  • 与其他应用程序共享对您的应用程序数据的访问;
  • 正在向小部件发送数据;
  • 正在通过 搜索框架;
  • 正在与您的服务器同步应用程序数据;
  • 正在您的 UI 中加载数据。

TL;DR 简而言之,Content Provider 是一个允许您与其他人共享您的数据库的层 apps/widgets。所以 Google 可能在每个应用程序中都有一个内容提供者,它共享在这个应用程序上使用的帐户。


在 iOS:

现在我只是一名 Android 开发人员,但经过快速 Google 搜索后,我发现了这个 post which talks about UIPasteBoard:

Use the UIPasteboard class to let a user to share data from one place to another within your app, and from your app to other apps. For sharing data with any other app, use the systemwide general pasteboard; for sharing data with another app from your team—that has the same team ID as the app to share from—use named pasteboards.


我不能向您保证 Google 就是这样做的。但如果我要在我的应用程序中实现这样的功能,我会使用它。

AppGroup 通过创建一个共同的共享路径(如文档目录),允许在两个不同的应用程序甚至应用程序和小部件之间共享数据。保存在那里的数据可以被与该特定 AppGroup 关联的任何应用程序访问。它是应用程序之间的离线数据共享。 Communicating and persisting data between apps with App Groups