Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 8d7ab95

Browse files
Fix Android 12 PendingIntent
Fix Android 12 (SDK 31) notifications due to missing PendingIntent flags.
1 parent 0ceebc4 commit 8d7ab95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private PendingIntent toScheduleNotificationIntent(Bundle bundle) {
107107
notificationIntent.putExtra(RNPushNotificationPublisher.NOTIFICATION_ID, notificationID);
108108
notificationIntent.putExtras(bundle);
109109

110-
return PendingIntent.getBroadcast(context, notificationID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
110+
return PendingIntent.getBroadcast(context, notificationID, notificationIntent, Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT);
111111
} catch (Exception e) {
112112
Log.e(LOG_TAG, "Unable to parse Notification ID", e);
113113
}
@@ -451,7 +451,7 @@ public void sendToNotificationCentreWithPicture(Bundle bundle, Bitmap largeIconB
451451
int notificationID = Integer.parseInt(notificationIdString);
452452

453453
PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationID, intent,
454-
PendingIntent.FLAG_UPDATE_CURRENT);
454+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT);
455455

456456
NotificationManager notificationManager = notificationManager();
457457

0 commit comments

Comments
 (0)