本文介绍了类型'AuthDataResult'的值没有成员'providerID'Firebase 5.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对最新版本的FirebaseAuth 5.0有疑问 这是我的代码:
I have a problem with the newest version of FirebaseAuth 5.0 this is my code:
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中,此方法有效.谢谢!
problem is "Value of type 'AuthDataResult' has no value "ProviderID" " But in firebase 4 this method worked. Thanks!
推荐答案根据参考文档,createUser函数通过(FIRAuthDataResult?, Error?)传递完成块. FirAuthDataResult与User不同,但是它具有User作为属性,可以这样访问:
According to the reference docs, the createUser function passes a completion block with (FIRAuthDataResult?, Error?). FirAuthDataResult is not the same as a User, but it has a User as a property, which can be accessed like this:
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) } }更多推荐
类型'AuthDataResult'的值没有成员'providerID'Firebase 5.0
发布评论