本文介绍了我如何创建一个用户的信息显示名称,用户名&用户照片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我如何创建一个用户显示名称,用户名和密码?我可以用这个代码吗? 如果让user = FIRAuth.auth()?。currentUser let name = user.displayName let email = user.email let photoUrl = user.photoURL let uid = user.uid ; // Firebase项目所特有的用户ID。 //不要使用这个值来验证 //你的后端服务器,如果你有的话。使用 // getTokenWithCompletion:completion:改为。 } else { //没有用户登录。} 如果没有,为什么这个代码被使用? 哪些代码可以用来确定用户名,个人资料图片等? 我是firebase的新手。 然而,它们不能被编辑自定义字段,如 Firebase数据库。 要允许用户自定义字段,您需要使用相同的唯一 uid 您在用户的身份验证中收到。像这样的东西 if let user = FIRAuth.auth()?currentUser { let name = user.displayName let email = user.email let photoUrl = user.photoURL let uid = user.uid; let ref = FIRDatabase.database()。reference() let key = uid let userDict = [name:name, email:email,photoUrl:photoUrl] let childUpdates = [/ users / \(key):userDict] ref.updateChildValues(childUpdates ,withCompletionBlock:{(error,ref) - >无效 //现在用户存在于数据库中})} pre> 我们把它放在我们的数据库的 users 终点处,并用 uid 键由以下行 / users / \(key)。 How can i create a user with info about Display Name, username & Profile pic?Can I use this code?if let user = FIRAuth.auth()?.currentUserlet name = user.displayNamelet email = user.emaillet photoUrl = user.photoURLlet uid = user.uid; // The user's ID, unique to the Firebase project. // Do NOT use this value to authenticate with // your backend server, if you have one. Use // getTokenWithCompletion:completion: instead.} else { // No user is signed in.}If not, for what purpose this code is used?And which code can be used to determine username, profile pic etc,?I'm new to firebase. 解决方案 Firebase provides authentication for users using the FIRAuth Clases/APIHowever they can't be edited with custom fields like the Firebase Database.To allow custom fields for user, you need to duplicate users in the Database with the same unique uid you receive in the auth of the user. Something like thisif let user = FIRAuth.auth()?.currentUser { let name = user.displayName let email = user.email let photoUrl = user.photoURL let uid = user.uid; let ref = FIRDatabase.database().reference() let key = uid let userDict = [ "name" : name , "email" : email, "photoUrl" : photoUrl] let childUpdates = ["/users/\(key)": userDict] ref.updateChildValues(childUpdates, withCompletionBlock: { (error, ref) -> Void in // now users exist in the database })}We push it at the users end point in our db and with the uid key by the following line /users/\(key). 这篇关于我如何创建一个用户的信息显示名称,用户名&用户照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 07:32