I am a beginner in Firebase android development using Kotlin, my problem is I want to detect specific FirebaseAuthUserException using Kotlin. How do I achieve the desired result.
I have seen examples using JAVA but I could not figure it out how to implement it using Kotlin. Any Help is highly appreciated. Below is what I have written in my code:
private fun signInWithPhoneAuthCredential(credential: PhoneAuthCredential)
{
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this)
{ task ->
if (task.isSuccessful)
{
progressBar.visibility=View.INVISIBLE
gotomainactivity(
mAuth.currentUser!!.uid.toString()
,phoneNumber_to_verify)
}
else
{
//Handle task if not sign inis not sucessful due to phone
number already exist
val message=task.exception.toString()
Toast.makeText(this@RegisterActivity,"Error:
$message",Toast.LENGTH_SHORT).show()
progressBar.visibility=View.INVISIBLE
}
}
}
I expect to display to users using a toast if phone number already exist.