diff --git a/core/src/main/java/com/emarsys/core/util/AndroidVersionUtils.kt b/core/src/main/java/com/emarsys/core/util/AndroidVersionUtils.kt index f8e900e1..4cacfed5 100644 --- a/core/src/main/java/com/emarsys/core/util/AndroidVersionUtils.kt +++ b/core/src/main/java/com/emarsys/core/util/AndroidVersionUtils.kt @@ -5,12 +5,14 @@ import android.os.Build object AndroidVersionUtils { val isOreoOrAbove: Boolean get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - val isBelowTiramisu: Boolean - get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU val isBelowOreo: Boolean get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.O val isBelowQ: Boolean get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.Q val isBelowS: Boolean get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.S + val isBelowTiramisu: Boolean + get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU + val isBelowUpsideDownCake: Boolean + get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE } \ No newline at end of file diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/NotificationCommandFactory.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/NotificationCommandFactory.kt index 96b466c1..6fec8d1e 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/NotificationCommandFactory.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/NotificationCommandFactory.kt @@ -1,5 +1,6 @@ package com.emarsys.mobileengage.notification +import android.annotation.TargetApi import android.content.Context import android.content.Intent import com.emarsys.core.Mockable @@ -31,7 +32,7 @@ class NotificationCommandFactory(private val context: Context) { fun createNotificationCommand(intent: Intent): Runnable { val actionId = intent.action - val notificationData = if (AndroidVersionUtils.isBelowTiramisu) intent.getParcelableExtra("payload") else intent.getParcelableExtra("payload", NotificationData::class.java) + val notificationData = if (AndroidVersionUtils.isBelowUpsideDownCake) intent.getParcelableExtra("payload") else extractPayload(intent) val action = getAction(notificationData, actionId) val commands = createMandatoryCommands(notificationData) @@ -64,6 +65,11 @@ class NotificationCommandFactory(private val context: Context) { return CompositeCommand(commands.filterNotNull()) } + @TargetApi(34) + private fun extractPayload(intent: Intent): NotificationData? { + return intent.getParcelableExtra("payload", NotificationData::class.java) + } + private fun handlePushInformation(notificationData: NotificationData?): NotificationInformationCommand? { val campaignId = notificationData?.campaignId if (!campaignId.isNullOrEmpty()) {