如何让Android将应用程序数据存储在用户的Google帐户中,以便在新设备上安装时将其还原 [英] How to get Android to store app data in user's Google account so it is restored on-install on new devices

本文介绍了如何让Android将应用程序数据存储在用户的Google帐户中,以便在新设备上安装时将其还原的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在实施无登录系统在我们的网络,iOS和Android应用上,允许用户拥有永久身份,而无需任何注册/登录流程.

We're implementing a loginless system on our web, iOS, and Android app that allows the user to have a persistent identity without requiring any sign-up/sign-in flows whatsoever.

无登录的关键部分是依靠iOS和Android将我们的应用程序数据永久存储在用户的iCloud/Google帐户中,以便在每种情况下为用户自动恢复数据:

A key part of loginless is relying on iOS and Android to permanently store our app's data in the user's iCloud / Google account so that the data is automatically restored for the user in each of the scenarios:

  • (i)退出并重新打开该应用程序(在Android中使用 SharedPreferences ,在iOS中使用 UserDefaults 完成)
  • (ii)在同一设备上卸载并重新安装该应用程序(在Android¹, Keychain + NSUbiquitousKeyValueStore 键/值备份>在iOS中)
  • (iii)基于旧设备的备份设置新设备(在Android¹中通过键/值备份 UserDefaults + Keychain + iOS中的NSUbiquitousKeyValueStore )
  • (iv)在与用户以前使用该应用程序相同的iCloud/Google帐户登录的全新设备上安装该应用程序(在iOS中由 NSUbiquitousKeyValueStore 完成)
  • (i) Quitting and re-opening the app (accomplished with SharedPreferences in Android, UserDefaults in iOS)
  • (ii) Uninstalling and re-installing the app on the same device (accomplished with key/value backup in Android¹, Keychain + NSUbiquitousKeyValueStore in iOS)
  • (iii) Setting up a new device based on a backup of an old device (accomplished with key/value backup in Android¹, UserDefaults + Keychain + NSUbiquitousKeyValueStore in iOS)
  • (iv) Installing the app on a brand new device signed into the same iCloud / Google account that the user previously used the app with (accomplished with NSUbiquitousKeyValueStore in iOS)

我们剩下的唯一情况就是弄清楚如何完成Android的(iv).即使在这种情况下,Android中的键/值备份也会还原数据不是从旧设备的备份中设置了全新设备?

The only case we have remaining is figuring out how to accomplish (iv) for Android. Does key/value backup in Android restore the data in this case, even when the brand new device wasn't set up from a backup of an older device?

我们发现 Cloud Firestore

We've discovered the existence of Cloud Firestore and AccountManager during our research, but it seems like the data in Cloud Firestore is keyed on an device basis so it wouldn't accomplish (iv), and it seems like AccountManager requires asking permission from the user to ask for their accounts via android.permission.GET_ACCOUNTS, plus the whole design of loginless is intended not to ask the user for any personally identifiable information. Are we correct in these conclusions, or could Cloud Firestore be used to accomplish (iv)? Is there anything else we can use to accomplish (iv) in Android?

¹我们决定使用键/值备份代替自动备份,因为备份的频率大于自动备份的频率.在Android文档中查看有关差异的更多信息 .

¹ We decided to use key/value backup instead of auto backup because the frequency of backups is greater than that of auto backups. See more information on the difference in Android's documentation.

推荐答案

如果

Shared preferences should restore from the previous device if the android:allowBackup attribute is set to true. As far as I know this works if you have your phone backed up at Google (Drive).

这篇关于如何让Android将应用程序数据存储在用户的Google帐户中,以便在新设备上安装时将其还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆