From ea4b662fc60d3edf1bddc21a305d046f265df3e3 Mon Sep 17 00:00:00 2001 From: Boris Tacyniak Date: Mon, 30 Aug 2021 23:25:05 +0200 Subject: [PATCH] Merge pull request #2130 from cristianoccazinsp/patch-1 Fix Android 12 PendingIntent --- .../modules/RNPushNotificationHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java b/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java index be6e85046..2f8706474 100644 --- a/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java +++ b/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java @@ -76,7 +76,7 @@ private PendingIntent toScheduleNotificationIntent(Bundle bundle) { notificationIntent.putExtra(RNPushNotificationPublisher.NOTIFICATION_ID, notificationID); notificationIntent.putExtras(bundle); - return PendingIntent.getBroadcast(context, notificationID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); + 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); } public void sendNotificationScheduled(Bundle bundle) { @@ -323,7 +323,7 @@ public void sendToNotificationCentre(Bundle bundle) { int notificationID = Integer.parseInt(notificationIdString); PendingIntent pendingIntent = PendingIntent.getActivity(context, notificationID, intent, - PendingIntent.FLAG_UPDATE_CURRENT); + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT); NotificationManager notificationManager = notificationManager(); checkOrCreateChannel(notificationManager);