【发布时间】:2017-12-03 15:22:14
【问题描述】:
目前我正在尝试获取用户数据,但存在一个大问题。当前登录用户的 uid 与我数据库中同一用户的 UID 不同。这是您可以看到的两张图片。图片下方是我在 Swift 中的 SignUpController 中的代码。我需要它与数据库和身份验证相同。感谢帮助。
这是第二个
func emailSingUp(){
guard let email = emailTextField.text, let password = passwordTextField.text,let name = nameTextField.text else {
print("unsuccessful signup")
return
}
Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
if error != nil{
print(error!)
return
}
}
guard let uid = Auth.auth().currentUser?.uid else{
print("There is no UID to access")
return
}
let ref = Database.database().reference(fromURL: "https://yourapp.firebaseio.com/")
let userReference = ref.child("users").child(uid)
let values = ["name":name, "email":email]
userReference.updateChildValues(values) { (err, ref) in
if err != nil{
print(err!)
return
}
}
【问题讨论】:
标签: ios firebase swift3 firebase-realtime-database firebase-authentication