i have problem in firebase.auth.ApplicationVerifier

旧街凉风 提交于 2021-02-05 09:24:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!