我正在使用带有Ionic 4的Firebase电话身份验证来验证引用此链接link的用户的手机号码,但是却出现此错误
polyfills-es2015.js:3657未处理的承诺拒绝:没有verifyProof,sessionInfo或临时证明,无法创建PhoneAuthCredential
但是,如果我单击按钮三到四次,它实际上正在登录。 我还从官方插件将SMScode类型从数字更改为字符串。
这是我的代码
constructor(public afauth: AngularFireAuth, public firebaseAuthentication : FirebaseAuthentication, public navCtrl: NavController ) { }
ngOnInit() {
this.firebaseAuthentication.onAuthStateChanged().subscribe((user) => {
if (user) {
this.navCtrl.navigateRoot(['verification']);
} else {
this.navCtrl.navigateRoot(['']);
}
});
}
phoneAuth() {
this.firebaseAuthentication.verifyPhoneNumber("+919552869559", 30000).then((verificationID) => {
console.log(verificationID);
this.verificationID = verificationID;
}).catch((error) => {
});
}
signInWithCode(){
this.phoneAuth()
this.firebaseAuthentication.signInWithVerificationId(this.verificationID,'123456').then((user)=>{
console.log(user)
});
}
}
html
<ion-button (click)="signInWithCode()">Phone Auth</ion-button>