Kotlin中的PhoneAuthProvider出现实施错误

时间:2018-01-18 07:04:45

标签: android firebase kotlin firebase-authentication

当我尝试通过电话验证注册用户时,我收到运行时错误

  

kotlin.NotImplementedError:未实现操作:未实现

我的代码是

val phoneAuth: PhoneAuthProvider = PhoneAuthProvider.getInstance()
    phoneAuth!!.verifyPhoneNumber(
            "+91xxxxxxxxxx",        // Phone number to verify
            60,                 // Timeout duration
            TimeUnit.SECONDS,   // Unit of timeout
            this@MainActivity,               // Activity (for callback binding)
            mCallBacks)

 val mCallBacks = object : PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
        override fun onVerificationCompleted(p0: PhoneAuthCredential?) {
            TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        }

        override fun onVerificationFailed(p0: FirebaseException?) {
            TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
        }

        override fun onCodeSent(p0: String?, p1: PhoneAuthProvider.ForceResendingToken?) {
            super.onCodeSent(p0, p1)
        }

    }

2 个答案:

答案 0 :(得分:1)

TODO基本上会抛出NotImplementedError。您可以使用TODO等评论替换// TODO

答案 1 :(得分:-1)

那么只需从实现的函数中删除TODO(...),就可以了!例如

override fun onNegativeButtonPresssed() {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

从TODO中删除。