我有来自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
}
})
答案 0 :(得分:1)
您可以将错误从Error转换为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
中的所有可能错误