当我们使用Firebase for Android注册时,如何验证由Google验证的电子邮件ID? [英] How to verify email id authenticated by Google or not when we signup using the Firebase for android?

查看:1384
本文介绍了当我们使用Firebase for Android注册时,如何验证由Google验证的电子邮件ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户使用Android中的Firebase电子邮件/密码登录方法注册时,我们如何验证他们的电子邮件?

解决方案

对于Android电子邮件验证,首先您可以通过firebase



他们是否验证了他们的电子邮件?

  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!。);
}

}

不幸的是,您的验证电子邮件的内容/正文(我已经与Firebase进行了大量的对应,提供了可供选择的不太可怕的模板)。您可以更改标题或消息发件人ID,但这就是它的一切。



除非您将应用程序与自己支持的Web重新链接。 此处


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

解决方案

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.

这篇关于当我们使用Firebase for Android注册时,如何验证由Google验证的电子邮件ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆