cordova - Ionic2 身份验证 Firebase

标签 cordova firebase ionic2 firebase-authentication phone-number

我正在通过 ionic 2 中的手机号码创建一个身份验证系统,为此我使用了谷歌指南

首先,我相信一个firebase.auth.RecaptchaVerifier (是必要参数之一)

this.autVer = new firebase.auth.RecaptchaVerifier('contCatcha', {
'size': 'invisible',
'callback': function (response) {
// reCAPTCHA solved, allow signInWithPhoneNumber.
}
});

最后使用 auth.signInWithPhoneNumber angularfire
this.afAuth.auth.signInWithPhoneNumber("+57" + this.numeroCelular, this.autVer).then(verificationId => {
console.log("SMS Enviado");
this.confor = verificationId;
this.loading.dismiss();
this.estado = 1;
this.esperarCodigo();
})

其中第二个参数是创建的 firebase.auth.RecaptchaVerifier

在我电脑的浏览器中一切正常,但在 mobil 上显示以下错误消息:

我需要更换 firebase.auth.RecaptchaVerifier ,但我不知道是否有任何插件或子表要做,而且一切正常
我真的很感谢你的建议

最佳答案

首先,Cordova/Ionic 使用 file:///协议(protocol),因此 Recaptcha 无法在您的应用程序上运行(仅在浏览器上运行,因为它是 http)。 Firebase/Recaptcha 库检查 location.protocol 并期望 http/https 但如前所述,Cordova 并非如此。
一种可能的解决方法是在您的手机上运行本地服务器。例如cordova-httpd 或 cordova-plugins#local-webserver(或应用内 http 浏览器)。之后,您可以实现不可见的验证码(如 firebase 文档中所述)。但是,有时用户会得到一个弹出窗口来解决验证码,所以它并不理想。

由于在移动环境中使用验证码没有意义(至少在大多数情况下),我开始着手为 Cordova/Ionic 进行 firebase 电话身份验证的 native 实现。我从 iOS 版本开始。

有人可以支持我实现 java/android 版本吗?

https://github.com/guyromb/cordova-firebase-phoneauth

关于cordova - Ionic2 身份验证 Firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44081040/

相关文章:

javascript - 如何在带有 ionic 线的饼图中显示数据标签

cordova - 波纹模拟器 - node.js

angularjs - Paypal在单页应用中的实现

javascript - Firebase通过数组包含对象搜索数据库

seo - Firebase 为 SPA 托管 SEO

angular - 使用 TypeScript 以编程方式检查 Ionic 2 单选按钮

android - Android 设备上的 Ionic 应用程序实时重新加载失败 : connection to the server was unsuccessful

cordova - 从 JavaScript 插件访问 config.xml 首选项

javascript - cordova Pushplugin 无法在 iOS 中获取设备 token

android - 如何在 firebase 中跨多个设备处理同步主题