react-native-otp-verify
react-native-otp-verify copied to clipboard
Not detecting OTP automatically
can you provide any full-example with <TextInput> and etc.. I'm confused to where to place that code in my js file
I have 11 charcter hash code but same issue for me. Not detecting the otp automatically.
UPDATE
On OTP Component I managed to work this Auto detect OTP.
when calling this.getHash();
in componentDidMount
you will get the 11 character hash code which will then be used to add in our SMS body eg .
[#] Your AndroidApp code is: 589645
e56cQRXERi/ //this is the 11 character hash code
componentDidMount(){
this.getHash();
this.startListeningForOtp();
}
componentWillUnmount() {
RNOtpVerify.removeListener();
}
getHash = () =>
RNOtpVerify.getHash()
.then(console.log)
.catch(console.log);
startListeningForOtp = () => {
RNOtpVerify.getOtp()
.then(p => RNOtpVerify.addListener(this.otpHandler))
.catch(p => console.log(p));
}
otpHandler = (message: string) => {
console.log(message);
const otp = /(\d{6})/g.exec(message)[1];
console.log(otp);
this.setState({ otp });
RNOtpVerify.removeListener();
// Keyboard.dismiss();
}
same issue for me got confused with .ts file. can you please provide example in .js file?
ok cool
same
Hi guys, I used this package for auto verification of OTP. It works great, but at times its not detecting OTP. Do anyone have any idea of what's causing the problem? I'm stuck at this place for past few days. Any help would be great!
Actually problem is different hashcode for debug and release. when you will compare hashcode of debug and release it will be different
Please check your play service is up to date. I had the same problem and fixed it by updating the play service.
same issue, have any solution?
You will get 11 characters hash code that you have to use in your text message.
the text message would be like: Your 6-digit code: 329769 is valid for 10 minutes 1kTcOHIoaXD
Note: in the text message, the hash code must be in the next line.
The below code is working fine for me.
useEffect(() => {
this.getHash();
this.startListeningForOtp();
},[])
getHash = () =>
RNOtpVerify.getHash()
.then(console.log)
.catch(console.log);
startListeningForOtp = () => {
RNOtpVerify.getOtp()
.then(p => RNOtpVerify.addListener(this.otpHandler))
.catch(p => console.log(p));
}
otpHandler = (message) => {
const otp = /(\d{6})/g.exec(message)[1];
setMatchingOtp(otp);
RNOtpVerify.removeListener();
Keyboard.dismiss();
}
Is there a way to use this without putting the hash code in the text message?
@aakashtyagiwmp can you share here a snippet of how you implemented it? or a repo probably so people here could help.
I have weird issue. Otp detect work on builds (apk) but fails on bundles (aab)
@faizalshap
I have weird issue. Otp detect work on builds (apk) but fails on bundles (aab)
@faizalshap
Have you found a solution for the problem?
.aab created a different hash key in my case.
I have weird issue. Otp detect work on builds (apk) but fails on bundles (aab)
@faizalshap
.aab created a different hash key in my case.
@viv3kk make sure that the Hash is correct @mehdihussain9 the example is added Thanks 👍