简体   繁体   English

firebase 是否将当前用户数据自动存储在 flutter 中的手机上?

[英]Does firebase store current user data automatically on phone in flutter?

I just saw a tutorial, where the author although was using shared-ref to store the user name, email etc locally, but he didn't use anything to store currentUser on a flutter app, which was connected to firebase.我刚刚看到一个教程,作者虽然在本地使用 shared-ref 来存储用户名,email 等,但是他没有使用任何东西来将 currentUser 存储在 flutter 应用程序上,该应用程序连接到 ZBF12E1515C25C7D8C0352F1413AB9。 and hence in splash screen, he used if currentUser,= null, then goto Home Screen.因此在初始屏幕中,他使用 if currentUser,= null,然后转到主屏幕。 and it worked fine on restarting the app, hence to log out.并且在重新启动应用程序时效果很好,因此可以注销。 again he used firebaseAuth.signOut(), so?他再次使用了firebaseAuth.signOut(),所以呢? does firebase stores currentUser automatically on the local storage of the app? firebase 是否将 currentUser 自动存储在应用程序的本地存储中?

I don't think it's stored locally in terms of shared preferences/ user defaults.我不认为它是根据共享偏好/用户默认值存储在本地的。 I had an issue where without logging out, but uninstalling and reinstalling the app resulted in the app already knowing who I was.我有一个问题,没有注销,但卸载并重新安装应用程序导致应用程序已经知道我是谁。 Turns out, it was stored in keychain (on iOS, I don't know the android counterpart).原来,它存储在钥匙串中(在 iOS 上,我不知道 android 对应物)。 See this answer for more detail on my particular understanding of how firebase saves the user:有关我对 firebase 如何节省用户的特殊理解的更多详细信息,请参阅此答案:

https://stackoverflow.com/a/69621552/12132021 https://stackoverflow.com/a/69621552/12132021

Firebase Authentication SDKs store the credentials of the user in local storage, and then restore the user from there when the app restarts/page reloads. Firebase 身份验证 SDK 将用户的凭据存储在本地存储中,然后在应用程序重新启动/页面重新加载时从那里恢复用户。

Note that this doesn't always means that currentUser != null will work on app startup/page load, as restoring the credentials requires an asynchronous call to the server and currentUser will be null until that call completes.请注意,这并不总是意味着currentUser != null将在应用程序启动/页面加载时起作用,因为恢复凭据需要对服务器进行异步调用,并且currentUser将是null直到该调用完成。 For the best results listen/respond to authStateChanges as shown in the documentation on authentication state .为了获得最佳结果,请收听/响应authStateChanges ,如身份验证 state文档中所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter Firebase 获取当前用户数据 - Flutter Firebase get current user data 在 Flutter 中获取当前用户 uid 为 Firebase 的数据 - Fetch Firebase data with current user uid in Flutter 在 flutter 形式 firebase 中显示当前用户数据的任何方法? - any method to show current user data in flutter form firebase? 从 flutter 中的 firebase firestore 获取当前用户的数据 - Getting current user's data from firebase firestore in flutter 如何将每个用户的数据存储在 Flutter Firebase 实时数据库中? - How to store data for each user in Flutter Firebase Realtime Database? 如何在 Firebase 中为 Flutter 检查 null 当前用户 - How to check for null current user in Firebase for Flutter Flutter Firebase 匹配用户数据 - Flutter Firebase Matching user data Flutter Getx:谷歌登录和 map 数据到 firebase 自动让我以同一用户身份登录? - Flutter Getx: google signin and map data to firebase automatically logs me back in as same user? 如何在小部件上显示从 Firebase 到 Flutter 的当前用户数据 - How can I display on a widget the current user data from Firebase to Flutter 我想在我的 flutter 应用程序中从 firebase 数据库中获取当前用户数据 - I want to fetch current user data from firebase database in my flutter application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM