How to auto verify OTP in React Native on android?

QuestionsCategory: QuestionsHow to auto verify OTP in React Native on android?
Avishkar Patil asked 9 months ago

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));
 }
 };  

Please help me to get out from it.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.