I am trying to perform phone authentication(i,e OTP)
using firebase . Now i am receiving the OTP
from the firebase , But i want verify that OTP, And after successful verification it should to route another page called home
.I am unable to perform to verification process.
Below is my CODE:
HTML
<ion-content padding>
<ion-item>
<ion-label position="floating">Phone</ion-label>
<ion-input type="text" [(ngModel)]="phone"></ion-input>
</ion-item>
<ion-button expand="full" (click)="send()">Send</ion-button>
<ion-item>
<ion-label position="floating">Enter OTP</ion-label>
<ion-input type="text" [(ngModel)]="code"></ion-input>
</ion-item>
<ion-button expand="full" (click)="verify()">Verify</ion-button>
</ion-content>
TS
import { Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular';
import * as firebase from 'firebase';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
verificationId: any;
code = '';
phone: number;
constructor(public navCtrl: NavController) { }
ngOnInit() {}
send() {
const tell = '+91' + this.phone;
(<any> window).FirebasePlugin.verifyPhoneNumber(tell, 60, (credential) => {
console.log(credential);
this.verificationId = credential.verificationId;
}, (error) => {
console.error(error);
alert(error);
});
}
verify() {
const signInCredential = firebase.auth.PhoneAuthProvider.credential(this.verificationId, this.code);
firebase.auth().signInWithCredential(signInCredential).then((info) => {
console.log(info);
// this.navCtrl.navigateRoot('/home');
}, (error) => {
console.log(error);
});
}
}
While surfing i got this solution ,Here they are performing verification of the CAPTCHA also, I don’t want this functionality. I just want OTP verification.