When trying to authenticate a phone number in Ionic 3 using Firebase, the program runs without error. However, after entering the phone number, nothing happens...
The .html code is shown below:
<ion-item>
<ion-label stacked>Phone Number</ion-label>
<ion-input type="number" [(ngModel)]="phoneNumber"></ion-input>
</ion-item>
<button ion-button id="sign-in-button" (click)="signIn(phoneNumber)">Send OTP</button>
<ion-input type="number" placeholder="OTP" [(ngModel)]="code"></ion-input>
<button ion-button id="verify-in-button" (click)="verify()">Sign In</button>
The .ts file contains the following code:
export class HomePage {
verificationId: any;
code: string = "";
phoneNumber: number;
constructor(public navCtrl: NavController, public alertCtrl: AlertController) { }
signIn(phoneNumber)
{
(<any>window).FirebasePlugin.verifyPhoneNumber("+91" + phoneNumber,60,(credential)=>{
this.verificationId = credential.verificationId;
}, (error)=> {
alert("error" + error);
} );
}
verify()
{
let signInCredential =
firebase.auth.PhoneAuthProvider.credential(this.verificationId, this.code);
firebase.auth().signInWithCredential(signInCredential).then((info)=>{
}, (error)=>{
alert("error" + error);
} )
}
}
I am unsure of what I might be missing...