我正在尝试在带有隐形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
});