How to send email verification after user creation with Firebase Cloud functions?

后端 未结 5 921
遇见更好的自我
遇见更好的自我 2020-12-18 06:46

I\'m trying to send the verification email after the user is created. Since there\'s no way on Firebase itself, I\'m trying it with cloud functions.

I cannot really

5条回答
  •  余生分开走
    2020-12-18 07:03

    First view the documentation by Firebase here.

    As the registration phase completes and result in success, trigger the following function asynchronously :

     private void sendVerification() {
                 FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
                 user.sendEmailVerification().addOnCompleteListener(new OnCompleteListener() {
                    @Override
                    public void onComplete(@NonNull Task task) {
                        if (task.isSuccessful()) {
                             system.print.out("Verification Email sent Champion")
                              }
                             }
                    });
    }
    

    The user will now be provided with a verification Email. Upon clicking the hyper linked the user will be verified by your project server with Firebase.

    How do you determine whether or not a user did verify their Email?

     private void checkEmail() {
    
        FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    
        if (user.isEmailVerified()) {
               // email verified ...
        } else {
           // error : email 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.

提交回复
热议问题