firebase-kotlin-sdk
firebase-kotlin-sdk copied to clipboard
Firebase Auth get VerificationId
please tell me how can I get the verificationId, after onCodeSent method called from firebase, to pass it to the method
Firebase.auth.signInWithCredential(authCredential = PhoneAuthProvider().credential("??", "smsCode")) if automatic authorization did not work for some reason?
On the first screen of authorization I call PhoneAuthProvider().verifyPhoneNumber(phone, phoneVerificationProvider).
If automatic authorization did not work I need to pass verificationId and smsCode manually to the signInWithCredential, but I cannot find how can I get verificationId
@Daeda88 do we need to expose extra APs for this?
@nbransby I think yes, because the user only has a callback to send the SMS code again. It should look something like this:
override fun onCodeSent(verificationId: String, forceResending: PhoneAuthProvider.ForceResendingToken) {
verificationProvider.codeSent(**verificationId**) { android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, this, forceResending) }
}
Iirc, the PhoneVerificationProvider intterface should have a suspend function that returns the verificationId. Implementing the interface allows you to respond. But looking t it now, it probably needs some changes to work properly.
Note that each platform handles verification very differently and as such it difficult to actually unify the behaviour.
override fun onCodeSent(verificationId: String, forceResending: PhoneAuthProvider.ForceResendingToken) { verificationProvider.codeSent(**verificationId**) { android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, this, forceResending) } }
What was mentioned above is needed for Android. This would allow the saving of the verificationId for manually calling the 2nd exposed api method.
verificationProvider.codeSent(verificationId) is needed