From d0e6f33ac29cffd3b48491ae1154cac4e02881d9 Mon Sep 17 00:00:00 2001 From: Rehan Date: Tue, 17 Oct 2023 20:46:04 +0500 Subject: [PATCH 1/3] added flags --- .../customer/messagingpush/CustomerIOPushNotificationHandler.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt b/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt index 1d2d315d5..053f1f61c 100644 --- a/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt +++ b/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt @@ -226,6 +226,7 @@ internal class CustomerIOPushNotificationHandler( ): PendingIntent { val notifyIntent = Intent(context, NotificationClickReceiverActivity::class.java) notifyIntent.putExtra(NotificationClickReceiverActivity.NOTIFICATION_PAYLOAD_EXTRA, payload) + notifyIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK // In Android M, you must specify the mutability of each PendingIntent val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE From 25d5975e6c3137e5e1f35e5be9d3fdd4b5c19d48 Mon Sep 17 00:00:00 2001 From: Rehan Date: Tue, 17 Oct 2023 20:48:34 +0500 Subject: [PATCH 2/3] added comments --- .../customer/messagingpush/CustomerIOPushNotificationHandler.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt b/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt index 053f1f61c..196ef4775 100644 --- a/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt +++ b/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt @@ -226,6 +226,7 @@ internal class CustomerIOPushNotificationHandler( ): PendingIntent { val notifyIntent = Intent(context, NotificationClickReceiverActivity::class.java) notifyIntent.putExtra(NotificationClickReceiverActivity.NOTIFICATION_PAYLOAD_EXTRA, payload) + // Without these flags, Android OS does not launch activity again in one session if the activity was recently launched notifyIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK // In Android M, you must specify the mutability of each PendingIntent val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { From 2179847a3b220a8bd001ccef6a4ca1474575ee98 Mon Sep 17 00:00:00 2001 From: Rehan Date: Wed, 18 Oct 2023 12:45:15 +0500 Subject: [PATCH 3/3] leveraged launch mode --- messagingpush/src/main/AndroidManifest.xml | 1 + .../customer/messagingpush/CustomerIOPushNotificationHandler.kt | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/messagingpush/src/main/AndroidManifest.xml b/messagingpush/src/main/AndroidManifest.xml index a079c73b0..0c046b022 100644 --- a/messagingpush/src/main/AndroidManifest.xml +++ b/messagingpush/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ android:name=".activity.NotificationClickReceiverActivity" android:excludeFromRecents="true" android:exported="true" + android:launchMode="singleTop" android:noHistory="true" android:taskAffinity="" android:theme="@android:style/Theme.Translucent.NoTitleBar" /> diff --git a/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt b/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt index 196ef4775..1d2d315d5 100644 --- a/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt +++ b/messagingpush/src/main/java/io/customer/messagingpush/CustomerIOPushNotificationHandler.kt @@ -226,8 +226,6 @@ internal class CustomerIOPushNotificationHandler( ): PendingIntent { val notifyIntent = Intent(context, NotificationClickReceiverActivity::class.java) notifyIntent.putExtra(NotificationClickReceiverActivity.NOTIFICATION_PAYLOAD_EXTRA, payload) - // Without these flags, Android OS does not launch activity again in one session if the activity was recently launched - notifyIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK // In Android M, you must specify the mutability of each PendingIntent val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE