Martin
Martin

Reputation: 7310

Keep Firebase authentication state across iOS devices

I'm using Firebase Anonymous Authentication on iOS to let users use the app without creating an account.

It seems to be working good when testing but the problem will be to keep the user connected to the Anonymous-Firebase-user when for example uninstalling and installing the app again or when they switch to a new device (but are logged in with the same Apple id).

I understand I should prompt the users and ask to create an account (which I'm also doing) but I've learnt from before that users often don't want to create an account until they have already lost their data after switching device or uninstalling/installing again.

Is it possible to use Keychain https://firebase.google.com/docs/auth/ios/single-sign-on to keep the user logged in to the Anonymous-Firebase-user even if they uninstall the app or switch to a new device (but are logged in with the same Apple id)?

The documentation says "To share authentication states across multiple apps or extensions on iOS" but does it mean it could also keep the state when uninstalling or using the Apple id on another device?

Upvotes: 1

Views: 535

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599956

There is no way to retain Firebase's anonymous authentication state across app installs, or across devices. The anonymous user's token cannot be restored once it's deleted, and cannot be recreated on another device.

If you need this functionality, consider implementing your own custom identity provider in Firebase Authentication, that for example uses the Apple Id of the user as their identity. This will take part in your client-side code and in a server-side component.

Upvotes: 2

Related Questions