Persist user on App Reinstall with Firebase

穿精又带淫゛_ 提交于 2020-04-11 07:42:18

问题


When a user deletes and reinstalls my app, I want their anonymous user account to persist. My iOS app is working as expected, but Android is not. I create anonymous users like so

if (auth.getCurrentUser() == null) {
    auth.signInAnonymously().addOnCompleteListener(task -> {});
}

When I delete the app and reinstall, auth.getCurrentUser() is null and I have to re-authenticate.

My AndroidManifest.xml contains android:allowBackup="true"


回答1:


It is null becase Firebase Anonymous Authentication accounts does not persist across application uninstalls. If you uninstall the application, everything that was saved locally will be deleted, including the anonymous auth token that identifies that account. There is no way to reclaim that token for the user. You can use Firebase Anonymous Authentication to create and use temporary accounts to authenticate users in your application.

These temporary anonymous accounts can be used to allow users who haven't yet signed up to your app. If such an anonymous user decides later to sign up to your application, you can link their sign-in credentials to the anonymous account. What should you do, you should encourage your users to fully log in with a supported account provider so that they can log in from all their devices without worry of losing their data.



来源:https://stackoverflow.com/questions/46098543/persist-user-on-app-reinstall-with-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!