How to verify email id authenticated by Google or not when we signup using the Firebase for android?

后端 未结 1 1406
挽巷
挽巷 2020-12-11 14:19

When users signup using the Firebase Email/Password SIGN-IN METHOD in android, how can we verify their Emails ?

相关标签:
1条回答
  • 2020-12-11 15:10

    For Android Email verification, first you can view the documentation by firebase here.

    Send a user a verification email

    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    
    user.sendEmailVerification()
        .addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Log.d(TAG, "Email Sent.");
                }
            }
        });
    

    In my App whenever a user registers, sendEmailVerification(); is triggered

     private void sendEmailVerification() {
    
        FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    
        user.sendEmailVerification()
                .addOnCompleteListener(new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        if (task.isSuccessful()) {
                          Log.d(TAG, "Email verification sent.");                  
                        }
                    }
                });
    }
    

    Using the previous method, your users will now be provided with a verification Email. And it will look something a lot like this

    Did they verify their email ?

     private void IsEmailVerified() {
    
        FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    
        if (user.isEmailVerified()) {
               Log.d(TAG, "Email is verified.");
        } else {
              Log.d(TAG, "Email is not verified !.");
        }
    
    }
    

    Sadly, you may not customize the content/body of your verification Email ( I have been heavily corresponding with Firebase to provide alternative less hideous looking templates ). You may change the title or the message sender ID, but that's all there is to it.

    Not unless you relink your application with your own supported Web. Here.

    0 讨论(0)
提交回复
热议问题