I have the following structure in my Firebase:
users ->
uid ->
provider: "facebook.com"
username: "vandanpatel"
当我登录用户时,我只想检查他是否已经设置了用户名。我有获取当前用户的机制。我只想检查当前用户是否有“用户名”字段。我已经尝试了一切,但似乎没有什么对我有用。如果他们没有“用户名”字段,我会让他们选择“用户名”并进行设置。
最佳答案
你可以尝试:-
FIRDatabase.database().reference().child("users/\(FIRAuth.auth()!.currentUser!.uid)/username").observeSingleEvent(of: .value, with: {(snap) in
if snap.exists(){
//Your user already has a username
}else{
//You need to set the user's name and the the required segue
}
})
另请检查此链接:- Check if username already exists
关于ios - 如何检查 Firebase 中是否存在用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39928182/