gpt4 book ai didi

ios - PhoneAuth 火力地堡 : Update Phone number

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:29:51 25 4
gpt4 key购买 nike

我已经实现了 firebase phone auth 来验证我项目中的电话号码,它对我来说工作正常,但无法更新电话号码。比如一个用户用手机号 A 登录,现在他想把这个更新到手机号 B。这将如何解决?

最佳答案

我找到了一个答案,您可以使用您的电子邮件帐户登录并将手机号码更新到同一帐户中。您可以使用该解决方案使用电话登录并将电话号码更新到同一帐户中,看看它是否有效。无论如何,我将在我的项目中研究这个确切的解决方案,然后更新答案。但在那之前,您可以尝试看看这是否有效。按照此处给出的常规 firebase 电话身份验证程序进行操作:https://firebase.google.com/docs/auth/ios/phone-auth

PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber, uiDelegate: nil) { (verificationID, error) in
if let error = error {
self.showMessagePrompt(error.localizedDescription)
return
}
// Sign in using the verificationID and the code sent to the user
// ...
}

let credential = PhoneAuthProvider.provider().credential(
withVerificationID: verificationID,
verificationCode: verificationCode)

那就不要用下面的代码

// Sign In The User
Auth.auth().signInAndRetrieveData(with: credential) { _, error in

}

但是使用这段代码

Auth.auth().currentUser?.linkAndRetrieveData(with: credential, completion: { _, error in

if error == nil {
print("Whopdee doo")

} else {
print("Aargh!!!")
}
})

关于ios - PhoneAuth 火力地堡 : Update Phone number,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47633804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com