Send User Verification Email | Android Studio | Kotlin

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 Java

Video Tutorial:

Let's start:

How to verify?

private fun sendEmailVerification() {
        //get instance of firebase auth
        val firebaseAuth = FirebaseAuth.getInstance()
        //get current user
        val firebaseUser = firebaseAuth.currentUser
        
        //send email verification
        firebaseUser!!.sendEmailVerification()
            .addOnSuccessListener {
                Toast.makeText(this@ProfileActivity, "Instructions Sent...", Toast.LENGTH_SHORT).show()
            }
            .addOnFailureListener { e ->
                Toast.makeText(this@ProfileActivity, "Failed to send due to " + e.message, 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

Picture In Picture | Android Studio | Kotlin

Manage External Storage Permission | Android Studio | Kotlin

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