briankabiro / react-native-get-sms-android

React Native module to get messages on an Android device

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autosend is not working in android 12

Nsingh0007 opened this issue · comments

Autosend method is not working in android version 12.

Help me out for this issue.

Thanks!.

hey did you find any solution?

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

Not working, showing Flag_Immutable error

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)

@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."

commented

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'