Send User Verification Email | Android Studio | Java

Firebase Email Verification: 

Since any user can create an account in your firebase app whether this email exists in real or not so your app may need to verify that the email actually exists. You can easily send an email address verification email to a user with the sendEmailVerification method. 

>>Check For Kotlin

Video Tutorial:

Let's start:

How to verify?

private void sendEmailVerification() {

        FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
        FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();

        firebaseUser.sendEmailVerification()
                .addOnSuccessListener(new OnSuccessListener<Void>() {
                    @Override
                    public void onSuccess(Void unused) {
                        Toast.makeText(ProfileActivity.this, "Instructions Sent...", Toast.LENGTH_SHORT).show();
                    }
                })
                .addOnFailureListener(new OnFailureListener() {
                    @Override
                    public void onFailure(@NonNull Exception e) {
                        Toast.makeText(ProfileActivity.this, "Failed to send due to "+e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });
    }

You will receive an email like this

Send User Verification Email | Android Studio | Java


How to check if verified or not?

if (firebaseUser.isEmailVerified()) {
   Toast.makeText(this, "User is verified...", Toast.LENGTH_SHORT).show();
 } else {
   Toast.makeText(this, "User isn't verified...", Toast.LENGTH_SHORT).show();
 }

Done!

Comments

Popular posts from this blog

Manage External Storage Permission | Android Studio | Kotlin

Manage External Storage Permission | Android Studio | Java

Add a Back Button to Action Bar Android Studio (Kotlin)