andreyvital / react-native-android-sms-listener

Allows you to listen for incoming SMS messages using React Native
MIT License
358 stars 99 forks source link

Android Oreo (Api Version>=26 ) not working #31

Closed appielife closed 4 years ago

appielife commented 6 years ago

The package is not working for android version greater than 8. https://developer.android.com/guide/components/broadcast-exceptions.html

gj1118 commented 6 years ago

Can someone please confirm ?

Thanks Gagan

ghost commented 6 years ago

Confirmed. Not working for API Version >= 26

kr4ckhe4d commented 6 years ago

Solved the issue by Requesting SMS Read permission and SMS Receive permissions when starting the react native app.

import { PermissionsAndroid } from 'react-native';

componentDidMount() { this.requestReadSmsPermission(); }

async requestReadSmsPermission() { try { var granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.READ_SMS, { title: "Auto Verification OTP", message: "need access to read sms, to verify OTP" } ); if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("sms read permissions granted", granted);
granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.RECEIVE_SMS,{
title: "Receive SMS", message: "Need access to receive sms, to verify OTP" } ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { console.log("RECEIVE_SMS permissions granted", granted); } else { console.log("RECEIVE_SMS permissions denied"); } } else { console.log("sms read permissions denied"); }
} catch (err) { console.log(err); } }

ckOfor commented 5 years ago

Tried to use permissions API but the host Activity doesn't implement PermissionAwareActivity.

ironhide0396 commented 4 years ago

Tried the above steps , but still cant seem to make it work . Permissions always return NEVER_ASK_AGAIN . I have tried uninstalling the app,clearing data,changing version number but still of no use. Any other workaround or fix for this issue ?

shubham2102 commented 4 years ago

Ask for READ_SMS as well as RECEIVE_SMS permission, it will work in sdk version 28.

MajdAbuRoqa commented 4 years ago

tried the above solution , permissions granted but the message not read

PragyaSingla commented 4 years ago

Tried integrating this library but its not auto reading messages. Please provide any solution

venkatesh-appoids commented 4 years ago

@kr4ckhe4d you made my day