【问题标题】:How to check if username exists in Firebase [duplicate]如何检查用户名是否存在于 Firebase [重复]
【发布时间】:2017-02-17 02:22:16
【问题描述】:
I have the following structure in my Firebase:

users ->
         uid ->
               provider: "facebook.com"
               username: "vandanpatel"

当我登录用户时,我只想检查他是否已经设置了他的用户名。我有获取当前用户的机制。我只想检查当前用户是否有“用户名”字段。我已经尝试了一切,但似乎没有什么对我有用。如果他们没有“用户名”字段,我会让他们选择“用户名”并设置它。

【问题讨论】:

标签: ios swift firebase firebase-realtime-database firebase-authentication


【解决方案1】:

你可以试试:-

    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

【讨论】:

  • 我已经完成了这个独一无二的任务。我想要做的是当用户尝试登录时,如果他的用户名字段已经设置,我会将他转移到另一个页面,所以我要做的只是检查我当前的用户是否已经选择用户名与否。
  • 答案已更新,这将告诉您您的用户是否已经在 Firebase 中存储了用户名。
猜你喜欢
  • 2018-11-27
  • 2019-01-04
  • 2020-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多