2016-09-17 91 views
0

我從火力此錯誤,說:如何從firebase錯誤中獲取更多信息?

一個內部錯誤,打印和更多信息,檢查錯誤的詳細信息。

我怎麼能知道是什麼錯誤??,

這裏是我的代碼用於打印錯誤

let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString) 
    FIRAuth.auth()?.signInWithCredential(credential, completion: {(user, error) in 
     if error != nil { 
      SCLAlertView().showError("error #1", subTitle: (error?.localizedDescription)!) 
      return 
     } 
}) 
+1

只打印錯誤,而不是沒有錯誤.localizedDescription? - 這至少應該給你一些更多的信息,包括你已經獲得的本地化描述。 – Dallas

回答

0

您可以從錯誤錯誤轉換成NSError,然後得到錯誤代碼。所以你將能夠獲得FIRAuthErrorCode。

例如:

let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString) 
    FIRAuth.auth()?.signIn(with: credential, completion: {(user, error) in 
     if error != nil { 
      let castedError = error! as NSError 
      let firebaseError = FIRAuthErrorCode(rawValue: castedError.code) 
      if firebaseError != nil { 
       switch(firebaseError!) { 
       case .errorCodeWrongPassword: 
        //do something or break 
        break 
       default: 
        //do something or break 
        break 
       } 
      } 
     } 
    }) 

入住FIRAuthErrorCode here所有可能的錯誤

相關問題