1

I'm wondering specifically what kind of events (other than signing out and possibly disabling an account) that would end the lifetime of an anonymous sign-in.

Does it work the same was as with react native, as this answer: https://stackoverflow.com/a/46143694 ?

You don't need to set persistence. Firebase handles it for you by default. You just need to call this function to check whether user is logged or not:

firebase.auth().onAuthStateChanged((user) => { if (user) { console.log('user is logged'); } } This will not be triggered only if user has sign out or cleaned app data.

Can I rely on the anonymous sign-in to persist unless the user signs out, is disabled, or the app is uninstalled?

Robin Manoli
  • 2,162
  • 2
  • 25
  • 30
  • See https://stackoverflow.com/questions/40697185/how-long-does-an-anonymous-firebase-session-take-to-expire, https://stackoverflow.com/questions/37907096/firebase-authentication-duration-is-too-persistent – Frank van Puffelen Nov 28 '18 at 15:01

1 Answers1

1

Yes, you can rely on the anonymous account to persist in those cases. It would not be useful otherwise.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 1
    The wording in this document (https://firebase.flutter.dev/docs/auth/usage#anonymous-sign-in) makes it sound like even if you sign-out, the same account will be used next time. "If the user signs-out and reauthenticates anonymously again, they will be signed-in with the previously created account"...I think this is wrong – Code on the Rocks Sep 17 '20 at 23:17