Danial
Danial

Reputation: 451

Why FirebaseAuth currentUser() is kept after uninstall the app?

I am trying to get the login state of the user in Flutter, whenever I run my application for the first time (Only when I uninstall and reinstall the app) following code return a user.

I already tried to get the user from whenComplete and then both return the same.

 FirebaseAuth _firebaseAuth = FirebaseAuth.instance;    
 FirebaseUser user = await _firebaseAuth.currentUser();
 return user;

returned user is a platform user from my android device, and if I reload my app after install user will be removed.

Edit:

  1. I already tried all the steps in https://stackoverflow.com/a/48660787/979653
  2. I removed all the users from my Firebase
  3. My app showing a user id which is not in my Firebase.

Funny thing is minimizing the app removes the unknown user.

Upvotes: 6

Views: 2494

Answers (1)

Miguel Ruivo
Miguel Ruivo

Reputation: 17756

That happens because data will persist anyways offline in some cases regardless of the app being deleted or not, and thus, your previous Firebase user.

Referring to this answer:

It's because Android 6 has automatic backup. You need to tune android:allowBackup and android:fullBackupContent in your manifest tag if you don't want your data backed up or if you want to include or exclude some resources. It's not a bug.

So basically, add android:allowBackup="false" and android:fullBackupContent="false" in manifest.xml and you should be fine.

Upvotes: 4

Related Questions