如何在Firebase身份验证中更新用户的详细信息

时间:2019-06-01 17:00:48

标签: java android firebase firebase-authentication

我正在尝试使用firebase在android studio中开发一个应用,用户在注册后会验证其电子邮件地址。但是,即使在验证了电子邮件地址之后,每当我再次打开该应用程序时,它都会将我转发到“发送电子邮件验证码”页面。但是,如果我清除应用程序数据,则不存在相同的问题。

我尝试使用AuthStateListener(对此一无所知),但是没有用。

这是我尝试的代码。我也尝试了没有authstatelistener的尝试,但是同样的问题仍然存在

   mAuth=FirebaseAuth.getInstance();
    user=mAuth.getCurrentUser();
    authStateListener=new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            if(!user.isEmailVerified()){
                startActivity(new Intent(HomePage.this,VerifyEmail.class));
            }
        }
    };

如果我在注册的手机中打开该页面,则会进入验证电子邮件页面。但是清除数据后,它不会将我转发到该页面。

1 个答案:

答案 0 :(得分:0)

此问题的原因是FirebaseUser对象默认情况下在应用程序中缓存。这就是为什么清除应用程序数据时没有问题的原因。要在应用启动时修复此调用profileImage.layoutIfNeeded() profileImage.layer.cornerRadius = profileImage.frame.size.width / 2

FirebaseAuth.getCurrentUser().reload()