【发布时间】:2021-04-07 16:24:50
【问题描述】:
我正在尝试设置 OTP 验证,因此当用户输入他们的电话号码时,我向他们发送一个 pin 码,onCodeSent() 被调用并且我收到密码 pin,但问题是当 onVerificationCompleted() 是调用,我想转到另一个活动,用户可以在其中输入代码 pin 进行验证,但根本没有调用它,我不明白为什么。任何帮助将不胜感激,谢谢。
val auth = PhoneAuthOptions
.newBuilder(FirebaseAuth.getInstance())
.setPhoneNumber(phoneNumber)
.setTimeout(60L,TimeUnit.MILLISECONDS)
.setActivity(this)
.setCallbacks(object : PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
override fun onVerificationCompleted(p0: PhoneAuthCredential) {
// here i want to get the smscode and send it over the next activity to verify
// but this method is not called at all
Intent(this,ChangePasswordActivity::class.java).apply {
putExtra("code",p0.smsCode)
startActivity(this)
}
}
override fun onVerificationFailed(p0: FirebaseException) {
Timber.d("Firebase Exception ${p0.message}")
}
override fun onCodeSent(code: String, p1: PhoneAuthProvider.ForceResendingToken) {
super.onCodeSent(code, p1)
}
override fun onCodeAutoRetrievalTimeOut(p0: String) {
super.onCodeAutoRetrievalTimeOut(p0)
}
})
.build()
PhoneAuthProvider.verifyPhoneNumber(auth)
【问题讨论】:
标签: android kotlin firebase-authentication one-time-password