类型'AuthDataResult'的值没有成员'uid

时间:2019-04-12 10:03:33

标签: swift xcode firebase

因此,我尝试在Firebase上注册用户,但不能,因为我一直在代码底部显示“ FUser(_objectId:firUser!.user)的代码底部不断获取“ AuthDataResult类型的值没有成员'uid”” .uid ...

当我添加firUser!.user.uid时 它仍然不起作用,并给我一个错误“无法使用类型的参数列表调用类型'FUser'的初始化程序”,但是该函数自动填充,因此我不知道为什么会发生

 class func currentId() -> String {
        //an acces to the firebase authentciationa and//this is the user UId or the user id that is saved to our current user
        return Auth.auth().currentUser!.uid
    }

    class func currentUser() -> FUser? {
        //if if we have a current user

        //againNSdictionary is the same dicturionary but from objective c
        if Auth.auth().currentUser != nil {
            if let dictionary = UserDefaults.standard.object(forKey: kCURRENTUSER){
            return FUser.init(_dictionary: dictionary as! NSDictionary)
            }
        }
        return nil
    }
    // now to register the user

    class func registerUserWith(email: String, password: String, firstName: String, lastNmae: String, completion: @escaping (_ error: Error?) -> Void){
        //when firebase finishes it will give us these two varaibles
        Auth.auth().createUser(withEmail: email, password: password) { (firUser, error) in

            if error != nil {
                completion(error)

                //so it doesnt run the rest of the code
                return
            }



            let fUser = FUser(_objectId: firUser!.user.uid, _pushId: "", _createdAt: Date(), _upDatedAt: Date(), _firstName: firstName, _lastName: lastNmae,  _avatar: "", _phoneNumer: "")

0 个答案:

没有答案