Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for me, its showing timeout errror #99

Open
vishnulanka-dataevolve opened this issue Sep 7, 2023 · 22 comments
Open

Not working for me, its showing timeout errror #99

vishnulanka-dataevolve opened this issue Sep 7, 2023 · 22 comments

Comments

@vishnulanka-dataevolve
Copy link

vishnulanka-dataevolve commented Sep 7, 2023

Sometimes its showing timeout and some times its not even working. can anyone share me working example.

@ankitsharma29
Copy link

same issue face

@ankitsharma29
Copy link

useEffect(() => {
RNOtpVetify.getHash()
.then(console.log)
.catch(console.log);
RNOtpVetify.getOtp()
.then(p => RNOtpVetify.addListener(OTPHandler))
.catch(p => console.log(p));

return () => RNOtpVetify.removeListener();

}, []);

const OTPHandler = (message) => {
console.log(message);

// const otps = getNumberFromString('number', message?.body);
// if (otps && otps.length > 0 && otps[0].length === otpLength) {
//   console.log("message", message, otps);
// }
const otp = /(\d{6})/g.exec(message);
console.log("message otp", otp);
  // onFillOTPData(otp);
RNOtpVetify.removeListener();

}
timeout errror

@Azeem00786
Copy link

Azeem00786 commented Nov 29, 2023

i am also facing the same error here is my code snippet

async otpRead() {
    console.log('otpRead--> ');
    getHash()
      .then(hash => {
        console.log('hash--->', hash);
        // use this hash in the message.
      })
      .catch(console.log);

    startOtpListener(message => {
      // extract the otp using regex e.g. the below regex extracts 4 digit otp from message
      console.log('message-->', message);
      const otp = /(\d{4})/g.exec(message)[1];
      console.log('otp--->', otp);
    });
  }

@mariaalm20
Copy link

Any solution?

@MinhThu100200
Copy link

same issue :((((

@ankitch29
Copy link

Hello, we're still encountering this issue. Could someone please assist us?

@elencho
Copy link

elencho commented Feb 15, 2024

same issue, any solutions?

@faizalshap
Copy link
Owner

Please try in latest version and use hook if possible

@Suman028
Copy link

is this fix still facing same issue in latest version?

@mainu007
Copy link

same issue, any solutions please?

@tayyabrajpoot12
Copy link

same issue , any progress?

@palmtown
Copy link

Hello Community,

Unfortunately, it doesn't work for me either, and I'm using RN 0.74.5. Sometimes it shows time out error, others it doesn't, but simply doesn't work.

@Suman028
Copy link

what is the otp message you get? does it have a hash code?

@palmtown
Copy link

what is the otp message you get? does it have a hash code?

Hello @Suman028

Please note that no otp message is received at all. getHash does receive an event, but nothing from otp.

@Suman028
Copy link

in the otp message you get, there should be hash code right?

@palmtown
Copy link

in the otp message you get, there should be hash code right?

Hello @Suman028

Please note that startOtpListener never receives a message when an sms is received. The only event that is received is in getHash.then(...). This Meaning, the otp is never received.

@Suman028
Copy link

i asking in the message there should be hash code, if the hash code is not present the otp message would not be received

@palmtown
Copy link

i asking in the message there should be hash code, if the hash code is not present the otp message would not be received

Hello @Suman028

I believe I now understand your response clearly. I will apply it and respond with full details so other users can fix the issue as well very shortly.

@Suman028
Copy link

Suman028 commented Nov 15, 2024

hey here are the steps to get the hash string, if required - link

@palmtown
Copy link

hey here are the steps to get the hash string, if required - link

Hello @Suman028,

You are absolutely correct. The issue, at least for me, was simply overlooking the snippet in the instructions that states:

"In order to detect the message, the SMS message must include a hash that identifies your app. This hash can be obtained by using the getHash() method below."

This means that when you receive a text message, it must include the hash returned by getHash(); otherwise, the detection will not work.

For others who may encounter the same issue, please ensure that your SMS message includes the hash returned from getHash(). Additionally, one detail that wasn’t immediately clear is that you need to prepend the hash code with a # symbol for it to function correctly.

With that said, thank you for your insightful comments—they helped me resolve the issue! If you have a Buy Me a Coffee or Cash App link, feel free to share it, and I’d be happy to send you a coffee as a token of appreciation.

Ultimately, my problem boiled down to not thoroughly reading the instructions.

Exhibit 1:
image

@Suman028
Copy link

@palmtown I also R & D on this for 2-3 days and finally noticed the issue, happy that it worked

@palmtown
Copy link

Hello @Suman028 and community,

I submitted a PR at #128 which aims to ensure absolute clarity regarding the SMS message format required for the OTP functionality. Specifically:

  1. Emphasizes that the SMS message must include the hash generated by the getHash() method.

  2. Explicitly states that the hash must be prepended with a # symbol for the functionality to work correctly.

  3. Adds examples and restructured the relevant section to make this requirement stand out, reducing the likelihood of it being overlooked by developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests