离子火基电话认证。如何使用验证码?

时间:2020-04-13 12:26:35

标签: javascript firebase ionic-framework firebase-authentication

我正在尝试在带有隐形Recaptcha的ionic 4中使用Firebase电话auth。我已经将ReCaptcha属性设置为window对象。但是仍然出现以下错误

TypeError:无法读取未定义的属性'RecaptchaVerifier'

出了什么问题? 预先谢谢你

window.service.ts

 get windowRef(){
    return window;
 }

page.ts

constructor(public win :WindowService){}

 ngOnInit() {

   this.windowRef = this.win.windowRef; 
   this.windowRef.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', {
    'size': 'invisible',      // error on this line

  });
 }

send(){
    const appVerifier = this.windowRef.recaptchaVerifier;

    this.afauth.signInWithPhoneNumber("+XXXXXXXXXXXX", appVerifier).then(function (success) {

         // code sent  
}).catch(err =>{console.log(err})
}

.html

  <div id="recaptcha-container"></div>

尝试2

this.recaptchaVerifier =new firebase.auth.RecaptchaVerifier('sign-in-button', {
      'size': 'invisible',
      // same error
    });

0 个答案:

没有答案