I am trying to auto verify otp
using react-native-sms-retriever
on android devices
.
I have tried following way to achieve.
import SmsRetriever from 'react-native-sms-retriever';
// Get the phone number (first gif)
_onPhoneNumberPressed = async () => {
try {
const phoneNumber = await SmsRetriever.requestPhoneNumber();
} catch (error) {
console.log(JSON.stringify(error));
}
};
// Get the SMS message (second gif)
_onSmsListenerPressed = async () => {
try {
const registered = await SmsRetriever.startSmsRetriever();
if (registered) {
SmsRetriever.addSmsListener(event => {
console.log(event.message);
SmsRetriever.removeSmsListener();
});
}
} catch (error) {
console.log(JSON.stringify(error));
}
};
Following is my OTP format
OTP for your login to Orgpick is 3242. Please enter OTP within 10 minutes.
Also I have created sms
format as follows dummy key-SZ3KPh5voKE
Please guide me with following sms
format.
Shall I need to get same format from server end?
What changes need to be done at server side?
<#>OTP for your login to Orgpick is 3242. Please enter OTP within 10 minutes.SZ3KPh5voKE
While trying above solution it showing time out exception
Please help me to get out from it.
I have tried two libraries for auto otp verification but none of them worked for me then I have tried with following library its working fine.Please check answer i have uploaded here