firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

How can i use the PhoneVerificationProvider in jsMain

Open dQqAn opened this issue 1 year ago • 0 comments

i already check this page:

actual class PhoneAuthProvider(val js: firebase.auth.PhoneAuthProvider) {

    actual constructor(auth: FirebaseAuth) : this(firebase.auth.PhoneAuthProvider(auth.js))

    actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(firebase.auth.PhoneAuthProvider.credential(verificationId, smsCode))
    actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = rethrow {
        val verificationId = js.verifyPhoneNumber(phoneNumber, verificationProvider.verifier).await()
        val verificationCode = verificationProvider.getVerificationCode(verificationId)
        credential(verificationId, verificationCode)
    }
}

actual interface PhoneVerificationProvider {
    val verifier: firebase.auth.ApplicationVerifier
    suspend fun getVerificationCode(verificationId: String): String
}

and i cant use the PhoneVerificationProvider. Can you give me the correct code block for phone verification in jsMain?

My missing code block: what do i write instead of todo's?

val phoneVerificationProvider = object : PhoneVerificationProvider {
            override val verifier: firebase.auth.ApplicationVerifier
                get() = TODO()

            override suspend fun getVerificationCode(verificationId: String): String {
                TODO()
            }
        }

 coroutineScope.promise {
            PhoneAuthProvider(auth).verifyPhoneNumber(phoneNumber, phoneVerificationProvider)
        }

dQqAn avatar Sep 01 '23 00:09 dQqAn