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

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

问题描述

当用户在 Android 中使用 Firebase 电子邮件/密码SIGN-IN METHOD 进行注册时,我们如何验证他们的电子邮件?

解决方案

Android邮箱验证,首先可以通过firebase查看文档

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

 private void IsEmailVerified() {FirebaseUser 用户 = FirebaseAuth.getInstance().getCurrentUser();如果 (user.isEmailVerified()) {Log.d(TAG, "电子邮件已验证.");} 别的 {Log.d(TAG, "电子邮件未验证!.");}}

遗憾的是,您可能无法自定义验证电子邮件的内容/正文(我一直与 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天全站免登陆