本文介绍了updatePhoneNumber失败:第一个参数"phoneCredential"必须是有效的电话凭证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新PhoneNumber并继续收到以下错误.看着我印象深刻的文档,这是一种方法吗?
I am trying to updatePhoneNumber and keep getting the following error above. Looking at the docs I was under the impressing this is a method?
Js:
user.updatePhoneNumber({
phoneNumber: "+15618104444",
});
我也尝试在updateProfile方法中对此进行设置,但是仍然没有运气.
I tried setting this in the updateProfile Method as well and still no luck.
user.updateProfile({
displayName: displayName,
photoURL: photoURL,
phoneNumber: "+15618104444"
});
推荐答案
updatePhoneNumber需要电话凭据,因为该电话号码需要通过SMS进行验证.
updatePhoneNumber requires a phone credential since the phone number needs to be verified by 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);
});
这篇关于updatePhoneNumber失败:第一个参数"phoneCredential"必须是有效的电话凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!