Reputation: 383
I'm using firebase authentication to create users and log in.Is there any way to see if a new user logged in,different from the last one, on the same device?I'm trying to delete the local database if so.
Upvotes: 0
Views: 44
Reputation: 6263
A quick solution to this problem would be to use an attribute that is unique to every user; that is the user's UID (from FirebaseAuth).
Save this in a reliable storage like SharedPreferences. When a user logs in, simply compare the UID of the user with the one you have saved. If they match, it's the same user.
This is how you get the user UID:
val mAuth: FirebaseAuth = FirebaseAuth.getInstance()
val uid: String = mAuth.uid!! //UID
PS: If a user's UID doesn't match with the saved one after log in, remember to update the saved version.
I hope this helps.
Upvotes: 1