0

hi guys i'm trying to do auto login in my app but before login done i wonder if the user verified his email or no.

the problem : even if i verified my account the code doesn't see this and said false.

and here is my code.

class SignInActivity : BaseActivity<SignInViewModel, ActivitySignInBinding>(), Navigator {
private lateinit var preferenceManger: PreferenceManger

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    preferenceManger = PreferenceManger(applicationContext)
    autoLogin()
    binding.vm = viewModel
    viewModel.navigator = this
    addPrefManger()
}

private fun autoLogin() {
    DataUtils.firebaseUser = Firebase.auth.currentUser
    if (preferenceManger.getBoolean(Constants.KEY_IS_SIGNED_IN)) {
        when {
            DataUtils.firebaseUser!!.isEmailVerified -> {
                startActivity(Intent(this, HomeActivity::class.java))
                finish()
            }
            else -> {
                startActivity(Intent(this, VerificationActivity::class.java))
                finish()
            }
        }
    }
}

this line is always false even if i verified my account.

DataUtils.firebaseUser!!.isEmailVerified
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

1

While the verification status of the user profile is updated on the server as soon as they've clicked the link, it may take up to an hour before that information is synchronized to the Android app.

If you want to detect the email verification in the app before it is automatically synchronized, you can:

  • Sign the user out and in again.
  • Force reloading of the user profile (after the user has clicked the link) by calling reload on the user object. You can put a button in your UI to do this, or automatically call that, for example in the onResume of the activity.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807