Firebase数据库用户uid

时间:2018-07-19 02:52:58

标签: swift xcode firebase firebase-realtime-database

这是错误无法转换类型'字符串预期参数类型'用户'的值       var用户:用户?       fileprivate func fetchUser(){

    let uid = user ?? (Auth.auth().currentUser?.uid ?? "")

   // guard let uid = Auth.auth().currentUser?.uid else { return }

    Database.fetchUserWithUID(uid: uid) { (user) in
        self.user = user
        self.navigationItem.title = self.user?.username

        self.collectionView?.reloadData()

        self.paginatePosts()
    }
}

2 个答案:

答案 0 :(得分:1)

    Auth.auth().signInAndRetrieveData(with: credential) { (authResult, error) in
        if let error = error {
            // ...
            return
        }
        let uuid = Auth.auth().currentUser!.uid
    }

尝试这个。它可能会解决您的问题

答案 1 :(得分:0)

登录Firebase控制台时,UID应该在此处。您还可以通过如下所示的android编程获取用户UID:-

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();

enter image description here