我正在使用https://github.com/arnesson/cordova-plugin-firebase来实现firebase电话身份验证。
当我调用verifyPhoneNumber()...It时,控制我的verificationId。
代码示例:
this.firebase.verifyPhoneNumber(phoneNumber,60)
.then(
function (verificationId) {
console.log(verificationId)
return verificationId;
}
)
控制台输出:
Object {
instantVerification: false,
verificationId: "here verification id"
}
但是,它不会向给定的电话号码发送代码。
有什么帮助吗?
发布于 2018-07-18 23:06:44
正如我在文档中看到的那样,他们说在发送短信之前,你需要使用你的凭证登录。也许你在你的示例代码之前做了这件事,如果你不这样做,你就用这个代替你的代码:
window.FirebasePlugin.verifyPhoneNumber(number, timeOutDuration, function(credential) {
console.log(credential);
// ask user to input verificationCode:
var code = inputField.value.toString();
var verificationId = credential.verificationId;
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);
});
https://stackoverflow.com/questions/51404945
复制相似问题