faizalshap / react-native-otp-verify

React native sms verification without additional permissions
MIT License
241 stars 95 forks source link

Otp retrieval only works once #58

Closed jbrodriguez closed 1 year ago

jbrodriguez commented 2 years ago

Hi, thanks a lot for the great library !

I'm having the issue that the otp retrieval works only the first time.

If it's a successful retrieval, it's not much of an issue because I can log in the user.

But if there's a timeout or for some error the code is wrong (thinking about user hitting something like a resend code button), then the listener doesn't work.

i was reading google's doc and found this

// Starts SmsRetriever, which waits for ONE matching SMS message until timeout
// (5 minutes). The matching SMS message will be sent via a Broadcast Intent with
// action SmsRetriever#SMS_RETRIEVED_ACTION.
Task<Void> task = client.startSmsRetriever();

ref: https://developers.google.com/identity/sms-retriever/request#2_start_the_sms_retriever

so i was thinking maybe we need to actually create the client again (RNOtpVerify.getOtp()) after a message is retrieved ?

what are your thoughts on this ?

faizalshap commented 1 year ago

Hi @jbrodriguez yes you are correct and in case of timeout, the event fires with with "Timeout Error." So if you want then you can start listener again with RNOtpVerify.getOtp())