Firebase email authentication for PWAs on iOS

Viewed 81

I am using Firebase email authentication to implement the following login flow:

  1. User selects "Sign in via Email" in PWA
  2. User receives link in email inbox, clicks it
  3. User is redirected back to PWA, the sign in link is detected and use to sign in with Firebase authentication.

On Android this works well because to the way PWA (Web APKs) register an intent filter for the URL of app (see: https://developers.google.com/web/fundamentals/integration/webapks#android_intent_filters). That causes the link clicked in the email client to open in the PWA.

On iOS, things don't work nearly as well. The email client will open a browser (or worse, a preview overlay) even though the PWA for that URL is already installed on the device.

Is there a way to send the user to the installed PWA on iOS? Or would an alternative mechanism be needed? Sending a 6-digit code, having the user memorize it, switch manually to the PWA, and enter it there?

I am thinking about using a Firebase function that generates the random code, stores it in Cloud Firestore along with the email address, and protected by a security rule (so only the Admin SDK can read it). Then a second function which receives the token input and email address by the user, checks for the token, and if the value matches, issues a custom token (https://firebase.google.com/docs/auth/admin/create-custom-tokens) that can be used to sign in.

0 Answers
Related