How to resend SMS verification in Firebase Phone Authentication Android?

前端 未结 3 1017
梦如初夏
梦如初夏 2021-01-07 19:41

According to Firebase documentation (https://firebase.google.com/docs/auth/android/phone-auth#send-a-verification-code-to-the-users-phone), there is callback fo

3条回答
  •  感动是毒
    2021-01-07 19:58

    Updated code

    fun resendOTP(activity: Activity,mobileNo: String){
        val options = PhoneAuthOptions.newBuilder(auth)
            .setPhoneNumber(mobileNo) // Phone number to verify
            .setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
            .setActivity(activity) // Activity (for callback binding)
            .setCallbacks(callback) // OnVerificationStateChangedCallbacks
            .setForceResendingToken(resendToken!!) // ForceResendingToken from callbacks
            .build()
        PhoneAuthProvider.verifyPhoneNumber(options)
    }
    

    For java see Github

    Thanks to GGWP for link .

提交回复
热议问题