Closed junebugfix closed 2 years ago
@DanielEliraz @weihangChen Is this something you can help push through to production?
I'm also experiencing the issue and can confirm @hankhester suggestion fixes the issue for me too.
thanks guys, new version with fix will come soon.
fixed in 4.2.0
In Android 12, you must specify the mutability of any
PendingIntent
, or the app throws anIllegalArgumentException
(see docs).Currently, when calling
postLocalNotification
, this library tries to create aPendingIntent
without a flag specifying the mutability, causing this error.NotificationIntentAdapter.java
line 15I believe the fix might be as simple as adding a mutability flag, probably
FLAG_IMMUTABLE
since it seems like that one is used in the majority of cases, but that would change the mutability of the intent, since before Android 12,PendingIntent
s were considered mutable by default.Making this change in the same place mentioned above fixed the crash for me:
I was able to get a minimal repro of this crash with the following steps:
expo init example-app
cd example-app
expo eject
yarn add react-native-notifications
android/build.gradle
android/app/src/main/AndroidManifest.xml
, add theandroid:exported="true"
attribute to the<activity>
tag named "MainActivity"App.js
:Notifications.postLocalNotification({ title: "Local notification", body: "This notification was generated by the app!", extra: "data", });