I've successfully set up a passwordless sign-in flow on mobile (using dynamic links). It works on iOS and Android, as long as the sign-in link is opened on the same mobile device.
I would like to support the scenario where users sign-in on mobile, but open the link on their PC. Is this even possible?
When clicking the link on the PC, I currently see an empty page, with the URL configured in my ActionCodeSettings
:
const actionCodeSettings: FirebaseAuthTypes.ActionCodeSettings = {
handleCodeInApp: true,
url: 'https://the-url-i-see',
iOS: {
bundleId: '...',
},
android: {
packageName: '...',
installApp: true,
},
}
Which parts are missing on my end?
UPDATE
I'm one step closer: I created an index.html
to be served via https://the-url-i-see
:
if (firebase.auth().isSignInWithEmailLink(window.location.href)) {
email = window.prompt('Please provide your email for confirmation');
firebase.auth().signInWithEmailLink(email, window.location.href).then(() => {
console.log('Sign-in successful')
}).catch(e => {
console.error('Sign-in failed', e)
})
}
What works now:
index.html
What is still missing:
Mobile app is not notified about the sign-in (specifically, onAuthStateChanged
handler is not firing).
Meanwhile I've learned that this is not how Firebase Auth works. My new understanding, overly simplified:
firebase.auth()
realm (which will trigger onAuthStateChanged
in this realm)TL;DR: Passwordless sign-in across devices is not supported out-of-the-box