代码之家  ›  专栏  ›  技术社区  ›  Corner

使用IOS中的电话号码登录Firebase

  •  0
  • Corner  · 技术社区  · 4 年前

    我想通过电话号码登录firebase,但当我通过电话号码登录时,用户已经创建了。我的问题是:我如何才能把一些细节,如新用户的姓名,电子邮件和个人资料图片谁创造了作者。auth()。登录(使用:凭证)?

            Button(action: {
                        let verificationID = UserDefaults.standard.string(forKey: "authVerificationID")
                        let credential = PhoneAuthProvider.provider().credential(
                            withVerificationID: verificationID ?? "",
                            verificationCode: confirm)
                         
                            
                            Auth.auth().signIn(with: credential) { success, error in
                                if error == nil {
                                   UserDefaults.standard.set(true, forKey: "isLoggedIn")
                                    Continue = true
                                }
                            
                                else{
                                    print(error!)
                                    showConfirmError.toggle()
                                }
                            
                           
                            }
                        
                    }){
    
    1 回复  |  直到 4 年前
        1
  •  1
  •   Victor Morei    4 年前

    你可以直接链接账户。 以下是如何做到这一点的官方文件: https://firebase.google.com/docs/auth/ios/account-linking

        2
  •  1
  •   Swift Ninja    4 年前

    首先,您必须执行如下请求:

    let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()
    

    然后更改用户

    changeRequest?.displayName = displayName
    changeRequest?.commitChanges { (error) in
      // ...
    }
    

    https://firebase.google.com/docs/auth/ios/manage-users#update_a_users_profile