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.