簡體   English   中英

在 flutter 中跨應用程序重啟時維護 Firebase Auth Login state

[英]Maintaining Firebase Auth Login state across app restart in flutter

我正在制作一個 android-flutter 應用程序,在其中我使用 firebase_auth 插件使用他們的電話號碼登錄用戶

如果使用 email 登錄,我們可以將憑據保存在 sharedprefences 中,並在應用程序重新啟動時重新訪問以再次登錄。 但是,在使用電話號碼登錄時,收到的 otp 僅有效一次,我如何在應用重啟時保持登錄 state 呢?

FirebaseAuth的登錄 state 將在應用程序重新啟動之間保留在設備上。 You can get and listen to the current auth state of the app using the FirebaseAuth.instance.onAuthStateChanged stream and show screens appropriately or ask for the current signed in FirebaseUser with FirebaseAuth.instance.currentUser() which will return the logged in user or null如果沒有用戶登錄,一旦完成。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM