gpt4 book ai didi

ios - 如何从 firebase 错误中获取更多信息?

转载 作者:可可西里 更新时间:2023-11-01 02:14:30 25 4
gpt4 key购买 nike

我收到来自 firebase 的错误消息:

An internal error has occured, print and inspect the error details from more information.

我怎么知道错误是什么??,

这是我打印错误的代码

 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
}
})

最佳答案

您可以将错误从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 中所有可能的错误

关于ios - 如何从 firebase 错误中获取更多信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39541643/

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