I'm trying to add the Firebase Phone Authentication code inside a View Model using Kotlin. The problem is that the PhoneAuthProvider requires an activity. Does anyone know how can this code be implemented inside a View Model without the need of an activity?
Thanks!
val mCallbacks: PhoneAuthProvider.OnVerificationStateChangedCallbacks ...
val options = PhoneAuthOptions.newBuilder(auth).apply {
setPhoneNumber(phoneNumber)
setTimeout(120L, TimeUnit.SECONDS)
setActivity(this) <-------------------------- // Activity (for callback binding)
setCallbacks(mCallbacks)
}.build()
PhoneAuthProvider.verifyPhoneNumber(options)