Firebase电话身份验证不适用于自己的设备

时间:2018-08-08 13:25:22

标签: android firebase ionic-framework firebase-authentication ionic3

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

使用设备在同一设备上具有编号的应用程序和sim卡的设备进行Firebase身份验证不起作用。

它发送OTP,但不验证并且不响应功能

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

它可以在其他设备上使用。

我正在使用Cordova:https://www.npmjs.com/package/cordova-plugin-firebase。 还使用Ionic Framework Pro来构建应用程序。

编辑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)中的问题

使用自己的手机号码 credential.verificationId 时会出错! 在下面的功能中。

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);
});

1 个答案:

答案 0 :(得分:0)

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

转到

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

并添加测试电话号码。