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

房东的猫 提交于 2019-12-17 21:28:58

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/41437252/how-to-verify-email-id-authenticated-by-google-or-not-when-we-signup-using-the-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!