In my Android app, I am creating user and sending verification email. I want to proceed to the next page when the user has verified by clicking the link in the email received. However, the verification status didn't update so I cannot proceed. I have tried signing out and signing in again which works but I don't want to refresh the status in this way. Any ideas?
Here is my code:
public void onClickContinueBtn() {
final FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
user.reload().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()) {
if(!user.isEmailVerified()){
// not verified block
// get into here even if verified
} else {
// email verified, go to next page
}
} else {
// do nothing, or show error
}
}
});
}
I had same issue. I'm using FirebaseUI and automatically it creates user on Firebase DB even if email has not yet been verified. But Firebase give you possibility to check if email has been verified or not by means of method user.isEmailVerified
.Two possibilities:
You can refresh the user by calling reload
after every few seconds.
Example:
final Handler handler = new Handler();
final int delay = 5000; //milliseconds
handler.postDelayed(new Runnable(){
public void run(){
Toast.makeText(EmailVerificationActivity.this, "I'm here", Toast.LENGTH_SHORT).show();
handler.postDelayed(this, delay);
}
}, delay);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With