From 3600ca1f0d304865ae94f8d7631097548868ff4b Mon Sep 17 00:00:00 2001 From: amarose Date: Mon, 19 Aug 2024 13:12:30 +0200 Subject: [PATCH] feat(PPG - Flags): add ovveride for flags in handleBackgroundNotificationClick --- README.md | 2 +- library/src/main/java/com/pushpushgo/sdk/PushPushGo.kt | 10 +++++----- .../java/com/pushpushgo/sdk/push/NotificationUtils.kt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0a3cd87..36a0960 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ dependencyResolutionManagement { // /libs.versions.toml [versions] -ppgSdk = "2.1.0" +ppgSdk = "2.2.0" [libraries] ppg-sdk = { module = "com.github.ppgco.android-sdk:sdk", version.ref = "ppgSdk" } diff --git a/library/src/main/java/com/pushpushgo/sdk/PushPushGo.kt b/library/src/main/java/com/pushpushgo/sdk/PushPushGo.kt index 0dfcd20..74bba4f 100644 --- a/library/src/main/java/com/pushpushgo/sdk/PushPushGo.kt +++ b/library/src/main/java/com/pushpushgo/sdk/PushPushGo.kt @@ -41,7 +41,7 @@ class PushPushGo private constructor( ) { companion object { - const val VERSION = "2.1.0-20240509~1" + const val VERSION = "2.2.0-20240819~1" internal const val TAG = "PPGo" @@ -169,7 +169,7 @@ class PushPushGo private constructor( */ var defaultIsSubscribed: Boolean = false - var notificationHandler: NotificationHandler = { context, url -> handleNotificationLinkClick(context, url) } + var notificationHandler: NotificationHandler = { context, url, overrideFlags -> handleNotificationLinkClick(context, url, overrideFlags) } /** * function to check whether the given notification data belongs to the PPGo sender @@ -212,7 +212,7 @@ class PushPushGo private constructor( /** * helper function to handle click on notification from background */ - fun handleBackgroundNotificationClick(intent: Intent?) { + fun handleBackgroundNotificationClick(intent: Intent?, overrideFlags: Int = Intent.FLAG_ACTIVITY_NEW_TASK) { if (intent?.hasExtra(PushNotificationDelegate.PROJECT_ID_EXTRA) != true) return val intentProjectId = intent.getStringExtra(PushNotificationDelegate.PROJECT_ID_EXTRA) @@ -230,7 +230,7 @@ class PushPushGo private constructor( //TODO Remove duplicated code val notify = deserializeNotificationData(intent.extras) - notificationHandler(application, notify?.redirectLink ?: intentLink) + notificationHandler(application, notify?.redirectLink ?: intentLink, overrideFlags) intent.removeExtra(PushNotificationDelegate.PROJECT_ID_EXTRA) uploadDelegate.sendEvent( @@ -363,6 +363,6 @@ class PushPushGo private constructor( fun createBeacon(): BeaconBuilder = BeaconBuilder(uploadDelegate) } -typealias NotificationHandler = (context: Context, url: String) -> Unit +typealias NotificationHandler = (context: Context, url: String, overrideFlags: Int) -> Unit typealias InvalidProjectIdHandler = (pushProjectId: String, pushSubscriberId: String, currentProjectId: String) -> Unit diff --git a/library/src/main/java/com/pushpushgo/sdk/push/NotificationUtils.kt b/library/src/main/java/com/pushpushgo/sdk/push/NotificationUtils.kt index d3c8f01..ea11241 100644 --- a/library/src/main/java/com/pushpushgo/sdk/push/NotificationUtils.kt +++ b/library/src/main/java/com/pushpushgo/sdk/push/NotificationUtils.kt @@ -38,9 +38,9 @@ internal fun deserializeNotificationData(data: Bundle?): PushPushNotification? { ) } -internal fun handleNotificationLinkClick(context: Context, uri: String) { +internal fun handleNotificationLinkClick(context: Context, uri: String, overrideFlags: Int) { Intent.parseUri(uri, 0).let { - it.addFlags(FLAG_ACTIVITY_NEW_TASK) + it.addFlags(overrideFlags) try { context.startActivity(it) } catch (e: ActivityNotFoundException) {