根据旧文档,firebase 提供身份验证错误作为 firebase 错误,它在其中提供了代码,但在新的 firebase 9.0.2 中,它只会出现异常,它可以转换为 FirebaseAuthException 并且具有 getCode 但字符串。现在我想得到 firebase 中所有可能的错误。我试过但找不到任何解决方案。 Ios 有句柄错误部分,并使用代码(int)提供错误,而在 Android 中没有。请帮忙。提前致谢
最佳答案
要获取 FirebaseAuth 中所有可能的错误,您可以执行以下操作:
private void handleAuthenticationException(@NonNull Exception exception) {
if (exception instanceof FirebaseAuthUserCollisionException) {
if (((FirebaseAuthUserCollisionException) exception).getErrorCode().equals("ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL")) {
//do something...
}
}
// Other relevant exceptions for you...
}
然后从您的 OnFailureListener 中调用此方法,如下所示:
firebaseAuth.signInWithCredential(credential).
.addOnSuccessListener(/*Your code here!*/)
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
handleAuthenticationException(exception);
}
);
请检查FirebaseAuthException文档以获取更多信息。
关于android - Firebase 9.0.2 身份验证错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37962109/