6

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.

Miguel Ruivo
  • 16,035
  • 7
  • 57
  • 87
Danial
  • 451
  • 6
  • 17
  • 2
    Does this answer your question? [Firebase Authentication returning specific user when app is uninstalled and Installed again](https://stackoverflow.com/questions/48660300/firebase-authentication-returning-specific-user-when-app-is-uninstalled-and-inst) – Christilyn Arjona Dec 18 '19 at 23:38
  • @Christilyn No luck, tried that and I also deleted all my users from firebase and it still returns uid when I check – Danial Dec 18 '19 at 23:50

1 Answers1

4

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.

Miguel Ruivo
  • 16,035
  • 7
  • 57
  • 87
  • 4
    And what about iOS devices? I am suffering from that same problem but on iOS – Waqas Younis Jun 04 '21 at 17:53
  • 1
    @WaqasYounis On iOS [it's related to Keychain](https://stackoverflow.com/questions/27893418/firebase-deleting-and-reinstalling-app-does-not-un-authenticate-a-user). – cubuspl42 Sep 28 '21 at 11:20