我遇到了这个令人沮丧的问题。令人恼火的是,他们很少或根本没有特定的文档来为Firebase进行这样的更新。我遇到了同样的错误:类型'AuthDataResult'的值没有成员'providerID'。这是我的代码:
if let user = user {
if self.segmentedControl.selectedSegmentIndex == 0 {
let userData = ["provider": user.providerID] as [String: Any]
DataService.instance.createFirebaseDBUser(uid: user.uid, userData: userData, isDriver: false)
} else {
let userData = ["provider": user.providerID, USER_IS_DRIVER: true, ACCOUNT_PICKUP_MODE_ENABLED: false, DRIVER_IS_ON_TRIP: false] as [String: Any]
DataService.instance.createFirebaseDBUser(uid: user.uid, userData: userData, isDriver: true)
}
}
答案 0 :(得分:1)
问题是代码中称为user
的对象不是FIRUser
,而是错误所指示的AuthDataResult
。
let authdataresult = // the thing you were calling user
let user = authdataresult.user // this is a FIRUser
let providerData = user.providerData // this is FIRUserInfo
let providerId = providerData.providerId
答案 1 :(得分:0)
我只需要在第一个用户之后添加另一个“用户”。不确定Google为什么要在最新的Firebase更新中进行此更改。
let userData = ["provider": user.user.providerID, "email": user.user.email]
DataService.instance.createDBUser(uid: user.user.uid, userData: userData as Dictionary<String, Any>)
userCreationComplete(true, nil)