Ionic2 authentication firebase

Viewed 12113

I am creating a system of authentication by number of cell phone in ionic 2, for that I use the google guide

First, I believe a firebase.auth.RecaptchaVerifier (Is one of the necessary parameters)

this.autVer = new firebase.auth.RecaptchaVerifier('contCatcha', {
'size': 'invisible',
'callback': function (response) {
// reCAPTCHA solved, allow signInWithPhoneNumber.
}
});

and laster use auth.signInWithPhoneNumber angularfire

this.afAuth.auth.signInWithPhoneNumber("+57" + this.numeroCelular, this.autVer).then(verificationId => {
console.log("SMS Enviado");
this.confor = verificationId;
this.loading.dismiss();
this.estado = 1;
this.esperarCodigo();
})

Where the second parameter is the firebase.auth.RecaptchaVerifier created

In the browser of my pc everything works fine, but on the mobil shows the following error message:

I need to replace that firebase.auth.RecaptchaVerifier, but I do not know if there is any plugin or sub meter to do and ahcer that everything works I really appreciate your advice

4 Answers

If you don't want to use dynamic/deep links as suggested by bojeil, you can try this:

Using Cordova, I moved all the authentication process to a webpage hosted on my server. From my app, I used an In-app Browser to launch the webpage, and then carry out all the app-browser communication by long-polling the server which acts as the middleman. I even managed to parse the SMS and close the browser in the end automatically.

For this to work, be careful with the security, which can be quite tricky.

Alternatively, you may use Firebase Realtime Database instead of server polling to pass around the messages.

You may need these cordova plugins:

  • InAppBrowser
  • BackgroundMode
  • Permission
  • Cordova SMS Receiver Plugin

I was not able to apply the workaround of @bojeil as I couldn;t find a way to have my own implementation of ApplicationVerifier. However, I was able to achieve Firebase Phone Authentication on Android using cordova firebase plugin as described in this video. Hope it helps.

Related