Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 类型为'的值;AuthDataResult';没有成员';providerID';Firebase 5.0_Ios_Firebase_Firebase Authentication - Fatal编程技术网

Ios 类型为'的值;AuthDataResult';没有成员';providerID';Firebase 5.0

Ios 类型为'的值;AuthDataResult';没有成员';providerID';Firebase 5.0,ios,firebase,firebase-authentication,Ios,Firebase,Firebase Authentication,我对FirebaseAuth 5.0的最新版本有问题 这是我的代码: func registerUser (withEmail email: String, andPassword password: String, userCreationComplete: @escaping (_ status: Bool, _ error: Error?) -> ()){ Auth.auth().createUser(withEmail: email, password: password)

我对FirebaseAuth 5.0的最新版本有问题 这是我的代码:

func registerUser (withEmail email: String, andPassword password: String, userCreationComplete: @escaping (_ status: Bool, _ error: Error?) -> ()){
    Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
        guard let user = user else{
            userCreationComplete(false, error)
            return
        }
        let userData = ["provider": user.providerID, "email": user.email]
        DataService.instance.createDBUser(uid: user.uid, userData: userData)
        userCreationComplete(true, nil)
    }

}
问题是“AuthDataResult类型的值”没有值“ProviderID”,但在firebase 4中,此方法有效。谢谢

根据,
createUser
函数通过带有
(FIRAuthDataResult?,Error?)的完成块
FirAuthDataResult
用户
不同,但它有一个
用户
作为属性,可以这样访问:

func registerUser (withEmail email: String, andPassword password: String, userCreationComplete: @escaping (_ status: Bool, _ error: Error?) -> ()){
    Auth.auth().createUser(withEmail: email, password: password) { (authResult, error) in
        guard let user = authResult.user else {
            userCreationComplete(false, error)
            return
        }
        let userData = ["provider": user.providerID, "email": user.email]
        DataService.instance.createDBUser(uid: user.uid, userData: userData)
        userCreationComplete(true, nil)
    }
}

欢迎来到堆栈溢出!请阅读并阅读,特别是如何提问。你在这里的最佳选择是做你的研究,搜索相关的话题,然后尝试一下。在做了更多的研究和搜索之后,发布一篇你尝试的文章,并明确指出你的困境所在,这有助于你获得更好的答案。我想请你在你的答案周围添加更多的上下文。只有代码的答案很难理解。如果你能在你的文章中添加更多的信息,这将有助于询问者和未来的读者。另请参见。您忘记了
guard let user=authResult?中的可选引用。user
func registerUser(withEmail email: String, andPassword password: String, userCreationComplete: @escaping (_ status: Bool, _ error: Error?) -> ()) {
    Auth.auth().createUser(withEmail: email, password: password) { (authResult, error) in
        guard let user = authResult?.user else {
            userCreationComplete(false, error)
            return
        }

        let userData = ["provider": user.providerID, "email": user.email]
        DataService.instance.createDBUser(uid: user.uid, userData: userData)
        userCreationComplete(true, nil)
    }
}