0

My project is a mobile project built with unity with firebase. I noticed that even when I delete the app, and re-download it from appstore, it will keep my login information.

It says here https://firebase.google.com/docs/auth/unity/manage-users#persist_a_users_credential that user's credential is persisted in the local keystore but is there a way to clear it/not save it when I delete the app?

It seems that disable firebase Auth State Persistence there is a javascript config to setPersistence but i could not find it for the unity C# library.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Pita
  • 1,444
  • 1
  • 19
  • 29
  • Did you see https://stackoverflow.com/questions/27893418/firebase-deleting-and-reinstalling-app-does-not-un-authenticate-a-user and more from https://www.google.com/search?q=%5Bfirebase-authentication%5D%5Bios%5D+remove+on+reinstall? – Frank van Puffelen Apr 21 '23 at 20:26

1 Answers1

0

By default, Firebase Authentication stores user credentials locally on the device to provide a better user experience, such as allowing users to remain authenticated across app restarts. This feature is called "persisting user authentication state."

If you want to disable this feature and clear the user's credentials when the app is deleted, you can call the FirebaseAuth.DefaultInstance.SignOut() method when the user logs out or when the app is deleted. This method signs out the current user and clears the persisted authentication state.

Unfortunately, there is currently no built-in method in the Firebase Unity SDK to disable authentication state persistence. However, you can try using the auth.SetPersistence() method to set the persistence state to "NONE" when the app starts up.

Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
auth.SetPersistence(Firebase.Auth.FirebaseAuth.Persistence.NONE);

This should prevent Firebase Authentication from persisting the user's authentication state across app restarts. Keep in mind that this approach will require the user to log in every time they open the app, which could potentially lead to a less optimal user experience.

ragerory
  • 1,360
  • 1
  • 8
  • 27
  • "Unfortunately, there is currently no built-in method in the Firebase Unity SDK to disable authentication state persistence. " I'm not sure I understand: isn't disabling authentication persistence precisely what the code snippet you give does? – Frank van Puffelen Apr 21 '23 at 20:23
  • We’re not disabling it, but resetting the persistence. It still exists but we are clearing it in this instance. Slight difference. – ragerory Apr 23 '23 at 01:26
  • That said… You are also the one who works on the Firebase project. So if I’m misinterpreting this, please feel free to correct. This has just been how I’ve understood it. – ragerory Apr 23 '23 at 01:39