How to catch a Firebase Auth specific exceptions

前端 未结 16 2347
慢半拍i
慢半拍i 2020-11-28 04:37

Using Firebase, how do I catch a specific exception and tell the user gracefully about it? E.g :

FirebaseAuthInvalidCredentialsException: The email ad

16条回答
  •  忘掉有多难
    2020-11-28 05:19

    you can use this:

    mAuth.getCurrentUser().linkWithCredential(authCredential)
                .addOnCompleteListener(this, new OnCompleteListener() {
                    @Override
                    public void onComplete(@NonNull Task task) {
                        if (task.isSuccessful()) {
                            Log.d(TAG, "linkWithCredential:success");
                        } else {
                            Log.w(TAG, "linkWithCredential:failure", task.getException());
                            Toast.makeText(getApplicationContext(), "Authentication failed. " + task.getException().toString, Toast.LENGTH_SHORT).show();
    
                        }
    
                        // ...
                    }
                });
    

提交回复
热议问题