Firebase 手机身份验证不适用于自己的设备



这是我的应用程序:https://play.google.com/store/apps/details?id=codechintan.risingbee.android

在同一设备上使用应用和SIM卡的设备进行Firebase身份验证不起作用。

它发送 OTP,但不验证,也不从函数响应

// sign in with the credential
firebase.auth().signInWithCredential(credential);

它适用于其他设备。

我正在使用科尔多瓦:https://www.npmjs.com/package/cordova-plugin-firebase。 也使用离子框架专业版来构建应用程序。

编辑 1

我们开发了一个应用程序,其中集成了使用 Firebase 的电话身份验证。

我们正在使用插件及其代码,插件链接 - https://www.npmjs.com/package/cordova-plugin-firebase

Android应用程序是使用Ionic框架和Cordova开发的。

它的电话身份验证不起作用,它会发送 OTP,但如果应用程序和电话号码在同一设备中,则电话验证不起作用。

示例:号码 +91 9575XXXXXX 在我的手机中,如果我在同一台设备上安装应用程序,身份验证过程将不起作用!它发送 OTP 但不验证!

现在,如果我尝试另一个号码(该号码不在具有应用程序的设备中的SIM卡(,身份验证过程将起作用。这很奇怪。

编辑 2

我认为,这是插件(https://www.npmjs.com/package/cordova-plugin-firebase(的问题

当使用自己的手机号码凭据时,验证ID变得错误! 在下面的函数中。

window.FirebasePlugin.verifyPhoneNumber(number, timeOutDuration, function(credential) {
console.log(credential);
// ask user to input verificationCode:
var code = inputField.value.toString();
var verificationId = credential.verificationId;
//THIS verificationId IS GETTING FALSE!!!
var credential = firebase.auth.PhoneAuthProvider.credential(verificationId, code);
// sign in with the credential
firebase.auth().signInWithCredential(credential);
// call if credential.instantVerification was true (android only)
firebase.auth().signInWithCustomToken(customTokenFromYourServer);
// OR link to an account
firebase.auth().currentUser.linkWithCredential(credential)
}, function(error) {
console.error(error);
});

此错误与模拟器上的firebase电话身份验证相关联,因此您需要提供测试电话号码

转到

firebase console -> Authentication -> SIGN-IN Method -> Phone

并添加测试电话号码。

最新更新