GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.17k stars 155 forks source link

How can i use the PhoneVerificationProvider in jsMain #417

Open dQqAn opened 1 year ago

dQqAn commented 1 year ago

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)
        }