【发布时间】:2017-07-22 23:22:42
【问题描述】:
我会在他注册时将用户数据保存到 firebase,但有一个问题是,如果他创建了 Auth 帐户,然后在保存他的信息之前失去了连接,这意味着他将获得没有任何个人资料信息的 Email\Password。
那么问题是如果他失去连接或退出应用程序,如何再次设置值?
FIRAuth.auth()?.createUser(withEmail: self.emailTxt.text!, password: self.passTxt.text!, completion: {
(user, error) in
if error != nil {
if let isError = error?.localizedDescription
{
print(isError)
} else {
print("Error: 33")
}
}
else if user != nil
{
// Email and password created
let userInfo: [String : Any] = ["timestamp": FIRServerValue.timestamp(),
"uid" : user!.uid,
"email" : self.emailTxt.text!,
// This info must be send again if its failed.
]
self.ref.child("users").child("profile").child((user?.uid)!).setValue(userInfo) {
(error, ref) in
if error != nil {
print("error set profile info")
// What should i do if its failed?
} else {
print("done creating user's profile")
}
}
}
}// Completion end.
【问题讨论】:
标签: firebase swift3 firebase-realtime-database firebase-authentication