Hello,
I’m trying to create phone number authentication with SMS
verification code in Ionic2
application using Firebase
phone provider Sing-in Method
.
verificationId: any;
code: string = "";
phoneNumber: number;
With sending();
of number to firebase
phone provider, receiving verification code with SMS and verification();
I have record of user phone number in Identifier
, Signed In
date, and User UID
in Firebase
account. Also I have this.insertRegistrationData();
which adds user phone number to separate database, needed to get user id for creation of app account, and recording of user data.
How to properly implement logged-in mode in this method for all pages. For example if I want load this.navCtrl.setRoot(UserSettingPage);
by previously create ID in separate database with retrieving of user app account data. I’m not quite understand this technique here:
sending(){
(<any>window).FirebasePlugin.verifyPhoneNumber("+" + this.phoneNumber, 60, (credential) => {
alert("SMS Sent Successfully");
console.log(credential);
this.verificationId = credential.verificationId;
}, (error) => {
console.log(error);
});
}
verification(){
let singlCredential = firebase.auth.PhoneAuthProvider.credential(this.verificationId, this.code);
firebase.auth().signInWithCredential(singlCredential).then((info)=>{
this.insertRegistrationData();
console.log(info);
}, (error)=>{
console.log(error);
});
}