类型“ AuthDataResult”的值没有成员“ providerID”

时间:2019-04-03 04:04:50

标签: swift firebase-authentication

最新版本的FirebaseAuth 5.0出现问题,这是我的代码:

if let email = emailField.text, let password = passwordField.text {          
    Auth.auth().signIn(withEmail: email, password: password) { (user, error) in
        if error == nil {
           if let user = user {
               if self.segmentedControl.selectedSegmentIndex == 0 {
                  let userData = ["provider": user.providerID] as [String: Any]

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

1 个答案:

答案 0 :(得分:0)

AuthDataResult的属性用户具有providerID。在AuthDataResult中,您不应将user视为completion。您可以按以下方式访问providerId

if let email = emailField.text, let password = passwordField.text {          
    Auth.auth().signIn(withEmail: email, password: password) { (authData, error) in
        if error == nil {
           if let user = authData?.user {
               if self.segmentedControl.selectedSegmentIndex == 0 {
                  let userData = ["provider": user.providerID] as [String: Any]