如何在与电子邮件相同的 child 中添加用户 phone 号码?
How can you add a user phone number in the same child as email?
用例:围绕电子邮件构建的应用程序(这里有三个重要的子项)。现在我只希望 cell phone 登录用户拥有相同的 Childs。
所以像下面这样的东西一定不会产生错误(目前确实如此)。我可以使用 phone 登录来做其他所有事情(甚至可以创建一个带有 phone 号码的用户),但我希望他也拥有这些 Childs,因为当用户使用 phone 而不是电子邮件时。
Auth.auth().createUser(withEmail: ResultString, password: remainingPart) { (user, error) in
let databaseRef = Database.database().reference()
guard error == nil else { return }
guard let user = user else { return }
let userObject =
[
"users": ResultString,
"postID": user.user.uid,
"e2": remainingPart,
] as [String: Any]
databaseRef.child("people").child(user.user.uid).setValue(userObject)
print("YESSSSS")
}
您似乎正试图将 phone 号码传递给 createUser(withEmail:,password:)
。由于 phone 号码不是有效的电子邮件地址,API 拒绝了它。
要使用 phone 号码登录用户,请按照 phone number sign-in 的文档进行操作。
在用 phone 号码让用户加入后,您仍然可以将他们的详细信息写入数据库,就像您现在所做的那样。
用例:围绕电子邮件构建的应用程序(这里有三个重要的子项)。现在我只希望 cell phone 登录用户拥有相同的 Childs。 所以像下面这样的东西一定不会产生错误(目前确实如此)。我可以使用 phone 登录来做其他所有事情(甚至可以创建一个带有 phone 号码的用户),但我希望他也拥有这些 Childs,因为当用户使用 phone 而不是电子邮件时。
Auth.auth().createUser(withEmail: ResultString, password: remainingPart) { (user, error) in
let databaseRef = Database.database().reference()
guard error == nil else { return }
guard let user = user else { return }
let userObject =
[
"users": ResultString,
"postID": user.user.uid,
"e2": remainingPart,
] as [String: Any]
databaseRef.child("people").child(user.user.uid).setValue(userObject)
print("YESSSSS")
}
您似乎正试图将 phone 号码传递给 createUser(withEmail:,password:)
。由于 phone 号码不是有效的电子邮件地址,API 拒绝了它。
要使用 phone 号码登录用户,请按照 phone number sign-in 的文档进行操作。
在用 phone 号码让用户加入后,您仍然可以将他们的详细信息写入数据库,就像您现在所做的那样。