我正在使用https://github.com/arnesson/cordova-plugin-firebase来实现Firebase电话身份验证。
当我调用verifyPhoneNumber()...时,它将为我提供验证ID。
this.firebase.verifyPhoneNumber(phoneNumber,60)
.then(
function (verificationId) {
console.log(verificationId)
return verificationId;
}
)
Object {
instantVerification: false,
verificationId: "here verification id"
}
但是,它没有将代码发送到给定的电话号码。
有什么帮助吗?
答案 0 :(得分:0)
正如我在文档中看到的那样,他们说您需要先使用凭据登录,然后再发送SMS。也许您在示例代码之前执行此操作,否则,请使用此代码代替您的代码:
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);
});