我正在尝试更新PhoneNumber并保持上面的错误。看着我印象深刻的文档,这是一种方法吗?
Js:
user.updatePhoneNumber({
phoneNumber: "+15618104444",
});
我也尝试在updateProfile方法中对此进行设置,但是仍然没有运气。
user.updateProfile({
displayName: displayName,
photoURL: photoURL,
phoneNumber: "+15618104444"
});
答案 0 :(得分:2)
updatePhoneNumber需要电话凭据,因为该电话号码需要通过SMS进行验证。
// 'recaptcha-container' is the ID of an element in the DOM.
var applicationVerifier = new firebase.auth.RecaptchaVerifier(
'recaptcha-container');
var provider = new firebase.auth.PhoneAuthProvider();
provider.verifyPhoneNumber('+16505550101', applicationVerifier)
.then(function(verificationId) {
var verificationCode = window.prompt('Please enter the verification ' +
'code that was sent to your mobile device.');
return firebase.auth.PhoneAuthProvider.credential(verificationId,
verificationCode);
})
.then(function(phoneCredential) {
return user.updatePhoneNumber(phoneCredential);
});