问题
error occur in second argument of signInWithPhoneNumber() and i am not able to fix this problem, in there is three method i used for send otp, verify otp and last on for captcha
methods:{
sendOTP(e){
e.preventDefault();
if(this.phoneNo.length!=10){
alert('Invalid No.');
}else{
let countryCode="+91"
let phoneNumber=countryCode+ this.phoneNo
let appVerifier=window.recaptchaVerifier
firebase.default.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
.then(function (confirmationResult){
console.log(confirmationResult);
window.confirmationResult=confirmationResult;
alert('SMS sent')
}).catch(function(err){
console.log(err);
alert('SMS not sent')
});
}
},
this method for verify OTP using firebase
verifyOTP(e){
e.preventDefault();
if(this.phoneNo.length!=10||this.otp.length!=6){
alert('Invalid format')
}
else{
let vm=this
let code=this.otp
//var user
window.confirmationResult.confirm(code).then(function (result){
console.log(result);
var user = user.result
vm.$router.push({path:'/home'})
})
}
},
here i initial the captcha method
initReCaptcha(){
setTimeout(()=>{
//let vm = this
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', {
'size': 'invisible',
'callback': function() {
// reCAPTCHA solved, allow signInWithPhoneNumber.
// ...
},
'expired-callback': function() {
// Response expired. Ask user to solve reCAPTCHA again.
// ...
}
});
//
this.appVerifier = window.recaptchaVerifier
},1000)
},
here i created captcha
created(){
this.initReCaptcha()
}
来源:https://stackoverflow.com/questions/61205884/i-have-problem-in-firebase-auth-applicationverifier