faizalshap / react-native-otp-verify

React native sms verification without additional permissions
MIT License
239 stars 92 forks source link

Timeout error #110

Open elencho opened 6 months ago

elencho commented 6 months ago

I get it that after 5 minute listener should be removed and started again but I think it doesn't work in my case:

` const otpHandler = (message: string) => { if (message !== 'Timeout Error.') { const otpMatch = /(\d{4})/g.exec(message) const otp = otpMatch ? otpMatch[1] : ''

        setValue(otp)
        Keyboard.dismiss()
        // removeListener()
        RNOtpVerify.removeListener()
    } else {
        startSmsListener()
        console.log('Timeout Error.')
    }
}

const startSmsListener = () => {
    if (System.isAndroid) {
        RNOtpVerify.getOtp()
            .then(() => RNOtpVerify.addListener(otpHandler))
            .catch()
        return () => {
            RNOtpVerify.removeListener()
        }
    }
}

useEffect(() => {
    startSmsListener()
}, [setValue])

}`

but it still doesn't work, this is logcat log i get:

image