I'm using Firebase along with the Javascript SDK using Expo. I'm trying to setup email-only authentication. Here are the steps I would like my users to experience when creating an account on their phones:
Open the app, select "sign in with email"
enter email and hit a "create account"
user get's a email verification email, switches over to the email client clicks the "verify" link
user is redirected to the app, which was waiting for the authentication to finish.
- App receives some sort of message saying the user is verified
- app logs in user
- user is happily logged in.
To do this, I use Expo.Linking.makeUrl to create a local URL that I can intercept upon redirection. I also created a simple function on Firebase which checks for a "redirectURL" query param and performs the redirection.
Here's my code:
import { Linking } from 'expo';
let expoLink = Linking.makeUrl('auth/email', { email: this.state.email });
let myRedirectFunction = 'https://<my app>.firebase.cloudfunctions.net/redirect&redirectUrl=' + encodeURIComponent(expoLink);
var actionCodeSettings = {
url: myRedirectFunction,
iOS: {
bundleId: '<my app>'
},
android: {
packageName: '<my app>',
installApp: true
},
handleCodeInApp: true
};
firebase.auth().sendSignInLinkToEmail(this.state.email, actionCodeSettings)
.then(...)
.catch(...);
the problem is that my function never gets invoked, instead the once the user clicks the verify link in the email, they are redirected to my project's default "Firebase hosting page".
No matter what url I specify in ActionCodeSetting.URL, it keeps redirecting to the hosted default page. I guess I could write some html which does the redirection, but I'm confused as to why Firebase did not simply invoke the URL I specified in ActionCodeSetting.URL.