How To Keep A User Persistent Logged In Through My Android Application With Firebase
Solution 1:
When a user of your app authenticates with Firebase, the Firebase client stores the token in the shared preferences on the user's Android device. So when the app restarts, the user is already authenticated (unless the token has expired).
So normally you'd only call Login()
(or show a "Log in" button) when the onAuthStateChanged()
gets null
for its authData
.
Solution 2:
I would suggest that once you get logged in to your main Activity store the logged in status in sharedPref as "logged" and move to your main activity.
The next time when the user opens the app check if the sharedPref is set to "logged" and move him to main Activity and on the onCreate() method of mainActivity authenticate yourself with Firebase thus mainitaining the logged status in Firebase.
Hope that helps !!
Post a Comment for "How To Keep A User Persistent Logged In Through My Android Application With Firebase"