I am working on a React Native app - sms-retriever API to read SMS automatically to retrieve OTP from message Following this article: https://github.com/Bruno-Furtado/react-native-sms-retriever
_onSmsListenerPressed = async () => {
alert('waiting for SMS')
try {
const registered = await SmsRetriever.startSmsRetriever();
if (registered) {
SmsRetriever.addSmsListener(event => {
console.log(event.message);
alert(event.message);
this.setState({message:event.message});
SmsRetriever.removeSmsListener();
});
}
} catch (error) {
console.log(JSON.stringify(error));
}
};
I'm running on an Android device When I press the button which calls the above message, it should start listening But when an SMS is received, it doesn't alert with SMS message What is wrong with the code?