briankabiro / react-native-get-sms-android

React Native module to get messages on an Android device
MIT License
137 stars 68 forks source link

Autosend is not working in android 12 #92

Closed Nsingh0007 closed 1 year ago

Nsingh0007 commented 2 years ago

Autosend method is not working in android version 12.

Help me out for this issue.

Thanks!.

MikeDaFirenze commented 1 year ago

hey did you find any solution?

Nsingh0007 commented 1 year ago

No, I didn't get any solution. Do you have any ..??

Awais6 commented 1 year ago

Not working, showing Flag_Immutable error

gofurnazarov commented 1 year ago

To make it work on Android 12 you should edit node_modules/react-native-get-sms-android/android/src/main/com/react/SmsModule.java file. In the file there are PendingIntent.getBroadcast(param1, param2, param3, 0) and PendingIntent.getActivity(param1, param2, param3, 0) methods that takes the last param 0. Change the last param to PendingIntent.FLAG_IMMUTABLE in all those methods.

Eg: PendingIntent.getBroadcast(mActivity, 0, new Intent("SENDING_SMS"), PendingIntent.FLAG_IMMUTABLE)

iyappan22 commented 1 year ago

@gofurnazarov still not working done that change still getting this error => "Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles."

nageshkinge commented 1 year ago

The solution suggested by @gofurnazarov works just you have to add the below line in node_modules/react-native-get-sms-android/build.gradle

implementation 'androidx.work:work-runtime:2.7.1'