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.
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
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
Post a Comment