Auth.auth().currentUser?.reload()不会刷新currentUser.isEmailVerified [英] Auth.auth().currentUser?.reload() doesn't refresh currentUser.isEmailVerified

查看:105
本文介绍了Auth.auth().currentUser?.reload()不会刷新currentUser.isEmailVerified的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Firebase实施电子邮件验证.我创建了可成功重定向到我的应用程序的动态链接.我也已经在网上测试了链接.它可以完美运行并验证电子邮件.但是,即使我事先运行了Auth.auth().currentUser?.reload()命令,验证电子邮件上的链接仍将我重定向到我的应用程序Auth.auth().currentUser.isEmailVerified仍然为我提供错误信息.

I'm trying to implement email verification with Firebase. I've created Dynamic Links that redirect to my app successfully. I have tested the link on the web too. It works perfectly and it verifies the email. However, the link on the verification email redirects me to my app, Auth.auth().currentUser.isEmailVerified still gives me false, even though I ran Auth.auth().currentUser?.reload() command beforehand.

对此有任何帮助吗?

推荐答案

Kotlin AndroidStudio 中,我使用了验证电子邮件!"按钮. 在此处输入图片描述

In Kotlin AndroidStudio I used a button "Verify Email!" enter image description here

班级:

private var b = false //verificacion email

按钮

in Class:

private var b = false //verificacion email

button

btnVerify.setOnClickListener{
            verifyEmail()
        }

然后

private fun verifyEmail(){
        val mAuth = FirebaseAuth.getInstance()
        mAuth.currentUser?.reload()?.addOnCompleteListener {
            b = mAuth.currentUser!!.isEmailVerified
            Log.d("VERI","state: $b")
            if(b){
                btnVerify.visibility = View.GONE
                yuorButton.visibility = View.VISIBLE //optional
            }else{
                Toast.makeText(applicationContext,"your email not verified", Toast.LENGTH_SHORT).show()
            }
        }
}

b是电子邮件验证状态.它将仅是"true".如果电子邮件已验证.注意力! "reload()";是异步的,并且"b"是异步的.获得真"将花费一些时间.对我来说,不到半秒钟.

b is the email verification status. It will only be "true" if the email is verified. Attention! "reload ()" is asynchronous and "b" will take a tiny while to get "true". For me it is less than half a second.

这篇关于Auth.auth().currentUser?.reload()不会刷新currentUser.isEmailVerified的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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