Not working for me, its showing timeout errror
Sometimes its showing timeout and some times its not even working. can anyone share me working example.
same issue face
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
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);
});
}
Any solution?
same issue :((((
Hello, we're still encountering this issue. Could someone please assist us?
same issue, any solutions?
Please try in latest version and use hook if possible
is this fix still facing same issue in latest version?
same issue, any solutions please?
same issue , any progress?
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.
what is the otp message you get? does it have a hash code?
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.
in the otp message you get, there should be hash code right?
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.
i asking in the message there should be hash code, if the hash code is not present the otp message would not be received
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.
hey here are the steps to get the hash string, if required - 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:
@palmtown I also R & D on this for 2-3 days and finally noticed the issue, happy that it worked
Hello @Suman028 and community,
I submitted a PR at https://github.com/faizalshap/react-native-otp-verify/pull/128 which aims to ensure absolute clarity regarding the SMS message format required for the OTP functionality. Specifically:
-
Emphasizes that the SMS message must include the hash generated by the getHash() method.
-
Explicitly states that the hash must be prepended with a # symbol for the functionality to work correctly.
-
Adds examples and restructured the relevant section to make this requirement stand out, reducing the likelihood of it being overlooked by developers.