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

编程入门 行业动态 更新时间:2024-10-28 10:23:55
本文介绍了类型'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

本文发布于:2023-11-26 06:00:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632922.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:成员   类型   AuthDataResult   providerID   Firebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!