gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 15:53:47 24 4
gpt4 key购买 nike

我对最新版本的 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 中此方法有效。谢谢!

最佳答案

根据reference docscreateUser 函数通过 (FIRAuthDataResult?, Error?) 传递完成 block 。 FirAuthDataResultUser 不同,但它有一个 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)
}
}

关于ios - 类型 'AuthDataResult' 的值没有成员 'providerID' Firebase 5.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51589895/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com