diff --git a/emarsys-sdk/src/androidTest/java/com/emarsys/InappNotificationIntegrationTest.kt b/emarsys-sdk/src/androidTest/java/com/emarsys/InappNotificationIntegrationTest.kt index 131a3750..e5b49f2f 100644 --- a/emarsys-sdk/src/androidTest/java/com/emarsys/InappNotificationIntegrationTest.kt +++ b/emarsys-sdk/src/androidTest/java/com/emarsys/InappNotificationIntegrationTest.kt @@ -15,7 +15,6 @@ import com.emarsys.mobileengage.event.EventServiceInternal import com.emarsys.mobileengage.iam.OverlayInAppPresenter import com.emarsys.mobileengage.service.IntentUtils import com.emarsys.mobileengage.service.NotificationData -import com.emarsys.mobileengage.service.NotificationMethod import com.emarsys.mobileengage.service.NotificationOperation import com.emarsys.testUtil.ConnectionTestUtils import com.emarsys.testUtil.DatabaseTestUtils @@ -137,7 +136,8 @@ class InappNotificationIntegrationTest { sid = SID, smallIconResourceId = 123, colorResourceId = 456, - notificationMethod = NotificationMethod("testCollapseId", NotificationOperation.UPDATE), + collapseId = "collapseId", + operation = NotificationOperation.INIT.name, actions = null, defaultAction = null, inapp = inappPayload diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/NotificationCommandFactoryTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/NotificationCommandFactoryTest.kt index 9b194edc..ad6f43ef 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/NotificationCommandFactoryTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/NotificationCommandFactoryTest.kt @@ -13,7 +13,15 @@ import com.emarsys.mobileengage.di.tearDownMobileEngageComponent import com.emarsys.mobileengage.event.CacheableEventHandler import com.emarsys.mobileengage.event.EventServiceInternal import com.emarsys.mobileengage.fake.FakeMobileEngageDependencyContainer -import com.emarsys.mobileengage.notification.command.* +import com.emarsys.mobileengage.notification.command.AppEventCommand +import com.emarsys.mobileengage.notification.command.CompositeCommand +import com.emarsys.mobileengage.notification.command.CustomEventCommand +import com.emarsys.mobileengage.notification.command.DismissNotificationCommand +import com.emarsys.mobileengage.notification.command.LaunchApplicationCommand +import com.emarsys.mobileengage.notification.command.NotificationInformationCommand +import com.emarsys.mobileengage.notification.command.OpenExternalUrlCommand +import com.emarsys.mobileengage.notification.command.TrackActionClickCommand +import com.emarsys.mobileengage.notification.command.TrackMessageOpenCommand import com.emarsys.mobileengage.push.PushInternal import com.emarsys.mobileengage.service.IntentUtils import com.emarsys.mobileengage.service.NotificationData @@ -49,7 +57,7 @@ class NotificationCommandFactoryTest { const val MULTICHANNEL_ID = "test multiChannel id" const val SMALL_RESOURCE_ID = 123 const val COLOR_RESOURCE_ID = 456 - val notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE) + val notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.INIT) val notificationData = NotificationData( null, null, @@ -61,7 +69,8 @@ class NotificationCommandFactoryTest { sid = SID, smallIconResourceId = SMALL_RESOURCE_ID, colorResourceId = COLOR_RESOURCE_ID, - notificationMethod = notificationMethod, + collapseId = COLLAPSE_ID, + operation = NotificationOperation.INIT.name, actions = null, defaultAction = null, inapp = null @@ -422,7 +431,8 @@ class NotificationCommandFactoryTest { "sid" to SID, "smallIconResourceId" to SMALL_RESOURCE_ID, "colorResourceId" to COLOR_RESOURCE_ID, - "notificationMethod" to notificationMethod.toString(), + "collapseId" to COLLAPSE_ID, + "operation" to notificationMethod.operation.name, "actions" to JSONArray( listOf( JSONObject( diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommandTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommandTest.kt index b6854ab9..3723b255 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommandTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommandTest.kt @@ -4,7 +4,6 @@ import android.app.NotificationManager import android.content.Context import android.content.Intent import com.emarsys.mobileengage.service.NotificationData -import com.emarsys.mobileengage.service.NotificationMethod import com.emarsys.mobileengage.service.NotificationOperation import com.emarsys.testUtil.TimeoutUtils import org.junit.Rule @@ -25,6 +24,7 @@ class DismissNotificationCommandTest { const val SID = "test sid" const val SMALL_RESOURCE_ID = 123 const val COLOR_RESOURCE_ID = 456 + val OPERATION = NotificationOperation.INIT.name val notificationData = NotificationData( null, null, @@ -36,7 +36,8 @@ class DismissNotificationCommandTest { sid = SID, smallIconResourceId = SMALL_RESOURCE_ID, colorResourceId = COLOR_RESOURCE_ID, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/PreloadedInappHandlerCommandTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/PreloadedInappHandlerCommandTest.kt index ad360c27..1d1bdbcb 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/PreloadedInappHandlerCommandTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/notification/command/PreloadedInappHandlerCommandTest.kt @@ -9,7 +9,6 @@ import com.emarsys.mobileengage.di.setupMobileEngageComponent import com.emarsys.mobileengage.di.tearDownMobileEngageComponent import com.emarsys.mobileengage.fake.FakeMobileEngageDependencyContainer import com.emarsys.mobileengage.service.NotificationData -import com.emarsys.mobileengage.service.NotificationMethod import com.emarsys.mobileengage.service.NotificationOperation import com.emarsys.testUtil.FileTestUtils import com.emarsys.testUtil.InstrumentationRegistry @@ -52,7 +51,8 @@ class PreloadedInappHandlerCommandTest { sid = SID, smallIconResourceId = SMALL_RESOURCE_ID, colorResourceId = COLOR_RESOURCE_ID, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = NotificationOperation.INIT.name, actions = null, inapp = null ) diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/IntentUtilsTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/IntentUtilsTest.kt index 9748fdc2..273dc8fd 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/IntentUtilsTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/IntentUtilsTest.kt @@ -41,7 +41,8 @@ class IntentUtilsTest { sid = SID, smallIconResourceId = SMALL_RESOURCE_ID, colorResourceId = COLOR_RESOURCE_ID, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = NotificationOperation.INIT.name, actions = null, inapp = null ) diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/MessagingServiceUtilsTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/MessagingServiceUtilsTest.kt index e423050e..ef1741da 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/MessagingServiceUtilsTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/MessagingServiceUtilsTest.kt @@ -60,14 +60,14 @@ class MessagingServiceUtilsTest { const val IMAGE_URL = "https://emarsys.com/image" const val ICON_URL = "https://emarsys.com/icon_image" const val HTML_URL = "https://hu.wikipedia.org/wiki/Mont_Blanc" - const val COLLAPSE_ID = "testCollapseId" const val COLOR = R.color.darker_gray const val MULTICHANNEL_ID = "test multiChannel id" const val SID = "test sid" + const val COLLAPSE_ID = "testCollapseId" + val OPERATION = NotificationOperation.INIT.name val SMALL_NOTIFICATION_ICON = com.emarsys.mobileengage.R.drawable.default_small_notification_icon - val NOTIFICATION_METHOD = NotificationMethod(COLLAPSE_ID, NotificationOperation.INIT) val EMPTY_NOTIFICATION_DATA: NotificationData = NotificationData( null, null, @@ -79,7 +79,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NOTIFICATION_METHOD, + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -228,9 +229,10 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, - inapp = null + inapp = null, ) val ems = JSONObject() @@ -296,7 +298,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -322,9 +325,10 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, - inapp = null + inapp = null, ) val input: MutableMap = HashMap() @@ -358,7 +362,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -393,7 +398,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -423,7 +429,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -456,7 +463,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -489,7 +497,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = colorResourceId, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -520,7 +529,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = invalidColor, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -549,7 +559,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -578,7 +589,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -614,7 +626,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -668,7 +681,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = actions.toString(), inapp = null ) @@ -710,7 +724,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -744,7 +759,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -865,7 +881,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -889,7 +906,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ) @@ -949,7 +967,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = actions, inapp = null ) @@ -1007,7 +1026,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = actions, inapp = null ) @@ -1051,7 +1071,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ), @@ -1083,7 +1104,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ), @@ -1119,7 +1141,8 @@ class MessagingServiceUtilsTest { sid = SID, smallIconResourceId = SMALL_NOTIFICATION_ICON, colorResourceId = COLOR, - notificationMethod = NotificationMethod(COLLAPSE_ID, NotificationOperation.UPDATE), + collapseId = COLLAPSE_ID, + operation = OPERATION, actions = null, inapp = null ), diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/NotificationActionUtilsTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/NotificationActionUtilsTest.kt index ea69964b..102499a9 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/NotificationActionUtilsTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/NotificationActionUtilsTest.kt @@ -27,14 +27,17 @@ class NotificationActionUtilsTest { const val COLOR_RESOURCE_ID = 456 const val SID = "test sid" const val MULTICHANNEL_ID = "test multichannel id" + const val COLLAPSE_ID = "testCollapseId" + val OPERATION = NotificationOperation.INIT.name val testNotificationData = NotificationData( campaignId = MULTICHANNEL_ID, sid = SID, smallIconResourceId = SMALL_RESOURCE_ID, colorResourceId = COLOR_RESOURCE_ID, - notificationMethod = NotificationMethod("123", NotificationOperation.INIT), - inapp = null, - actions = null + collapseId = COLLAPSE_ID, + operation = OPERATION, + actions = null, + inapp = null ) } diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV1Test.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV1Test.kt index c14d97f8..bbf5467b 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV1Test.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV1Test.kt @@ -151,14 +151,13 @@ class RemoteMessageMapperV1Test { @Test fun testMap_whenNotificationMethodIsSet() { - val notificationMethod = - NotificationMethod("testNotificationId", NotificationOperation.UPDATE) + val collapseId = "testNotificationId" val input: MutableMap = createRemoteMessage() input["image_url"] = IMAGE_URL input["channel_id"] = CHANNEL_ID val notificationMethodJson = JSONObject() - notificationMethodJson.put("collapseId", "testNotificationId") + notificationMethodJson.put("collapseId", collapseId) notificationMethodJson.put("operation", "UPDATE") val ems = JSONObject() ems.put("notificationMethod", notificationMethodJson) @@ -166,7 +165,8 @@ class RemoteMessageMapperV1Test { val notificationData = remoteMessageMapperV1.map(input) - notificationData.notificationMethod shouldBe notificationMethod + notificationData.collapseId shouldBe collapseId + notificationData.operation shouldBe NotificationOperation.UPDATE.name } @Test @@ -179,7 +179,7 @@ class RemoteMessageMapperV1Test { val notificationData = remoteMessageMapperV1.map(input) - notificationData.notificationMethod.operation shouldBe NotificationOperation.INIT + notificationData.operation shouldBe NotificationOperation.INIT.name } @Test @@ -195,7 +195,7 @@ class RemoteMessageMapperV1Test { val notificationData = remoteMessageMapperV1.map(input) - notificationData.notificationMethod.operation shouldBe NotificationOperation.INIT + notificationData.operation shouldBe NotificationOperation.INIT.name } @Test @@ -212,7 +212,7 @@ class RemoteMessageMapperV1Test { val notificationData = remoteMessageMapperV1.map(input) - notificationData.notificationMethod.operation shouldBe NotificationOperation.UPDATE + notificationData.operation shouldBe NotificationOperation.UPDATE.name } @Test @@ -228,7 +228,7 @@ class RemoteMessageMapperV1Test { val notificationData = remoteMessageMapperV1.map(input) - notificationData.notificationMethod.operation shouldBe NotificationOperation.INIT + notificationData.operation shouldBe NotificationOperation.INIT.name } @Test diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV2Test.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV2Test.kt index 55c073d4..b45277b8 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV2Test.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/service/RemoteMessageMapperV2Test.kt @@ -154,16 +154,15 @@ class RemoteMessageMapperV2Test { @Test fun testMap_whenNotificationMethodIsSet() { - val notificationMethod = - NotificationMethod("testNotificationId", NotificationOperation.UPDATE) - + val collapseId = "testNotificationId" val input: MutableMap = createRemoteMessage() - input["ems.notification_method.collapse_key"] = "testNotificationId" + input["ems.notification_method.collapse_key"] = collapseId input["ems.notification_method.operation"] = "UPDATE" val notificationData = remoteMessageMapperV2.map(input) - notificationData.notificationMethod shouldBe notificationMethod + notificationData.collapseId shouldBe collapseId + notificationData.operation shouldBe NotificationOperation.UPDATE.name } @Test @@ -172,7 +171,7 @@ class RemoteMessageMapperV2Test { val notificationData = remoteMessageMapperV2.map(input) - notificationData.notificationMethod.operation shouldBe NotificationOperation.INIT + notificationData.operation shouldBe NotificationOperation.INIT.name } @Test @@ -182,7 +181,7 @@ class RemoteMessageMapperV2Test { val notificationData = remoteMessageMapperV2.map(input) - notificationData.notificationMethod.operation shouldBe NotificationOperation.INIT + notificationData.operation shouldBe NotificationOperation.INIT.name } @Test 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 18a87866..187c18c1 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 @@ -169,7 +169,8 @@ class NotificationCommandFactory(private val context: Context) { json.put("sid", notificationData.sid) json.put("smallIconResourceId", notificationData.smallIconResourceId) json.put("colorResourceId", notificationData.colorResourceId) - json.put("notificationMethod", notificationData.notificationMethod) + json.put("collapseId", notificationData.collapseId) + json.put("operation", notificationData.operation) json.put("actions", actions) json.put("defaultAction", notificationData.defaultAction) json.put("inapp", notificationData.inapp) diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommand.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommand.kt index 488c1989..247d2072 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommand.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/notification/command/DismissNotificationCommand.kt @@ -11,7 +11,7 @@ class DismissNotificationCommand( override fun run() { val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - notificationData?.notificationMethod?.collapseId?.let { + notificationData?.collapseId?.let { manager.cancel(it, it.hashCode()) } } diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/MessagingServiceUtils.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/MessagingServiceUtils.kt index d7667f96..9eec1b6d 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/MessagingServiceUtils.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/MessagingServiceUtils.kt @@ -49,14 +49,14 @@ object MessagingServiceUtils { } else { val notificationManager = (context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager) - val collapseId = notificationData.notificationMethod.collapseId + val collapseId = notificationData.collapseId val notification = createNotification( context.applicationContext, deviceInfo, fileDownloader, notificationData ) - when (notificationData.notificationMethod.operation) { + when (NotificationOperation.valueOf(notificationData.operation)) { NotificationOperation.INIT, NotificationOperation.UPDATE -> { notificationManager.notify(collapseId, collapseId.hashCode(), notification) } diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/NotificationData.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/NotificationData.kt index 7f1590fe..d4fa1c79 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/NotificationData.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/NotificationData.kt @@ -15,7 +15,8 @@ data class NotificationData( val sid: String, val smallIconResourceId: Int, val colorResourceId: Int, - val notificationMethod: NotificationMethod, + val collapseId: String, + val operation: String, val actions: String? = null, val defaultAction: String? = null, val inapp: String? = null @@ -25,11 +26,10 @@ enum class NotificationOperation { INIT, UPDATE, DELETE } -@Parcelize data class NotificationMethod( val collapseId: String, val operation: NotificationOperation -) : Parcelable +) data class NotificationResourceIds( val smallIconResourceId: Int, diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV1.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV1.kt index fd13970f..819cdf48 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV1.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV1.kt @@ -43,20 +43,21 @@ class RemoteMessageMapperV1( val inapp = ems.getNullableString("inapp") return NotificationData( - image, - iconImage, - style, - title, - body, - channelId, - campaignId, - sid, - resourceIds.smallIconResourceId, - resourceIds.colorResourceId, - notificationMethod, - actions, - defaultAction, - inapp + imageUrl = image, + iconImageUrl = iconImage, + style = style, + title = title, + body = body, + channelId = channelId, + campaignId = campaignId, + sid = sid, + smallIconResourceId = resourceIds.smallIconResourceId, + colorResourceId = resourceIds.colorResourceId, + collapseId = notificationMethod.collapseId, + operation = notificationMethod.operation.name, + actions = actions, + defaultAction = defaultAction, + inapp = inapp ) } diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV2.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV2.kt index f5b499d5..7c463312 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV2.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/service/mapper/RemoteMessageMapperV2.kt @@ -34,20 +34,21 @@ class RemoteMessageMapperV2( val inapp = remoteMessageData["ems.inapp"] return NotificationData( - image, - iconImage, - style, - title, - body, - channelId, - campaignId, - sid, - resourceIds.smallIconResourceId, - resourceIds.colorResourceId, - notificationMethod, - actions, - defaultAction, - inapp + imageUrl = image, + iconImageUrl = iconImage, + style = style, + title = title, + body = body, + channelId = channelId, + campaignId = campaignId, + sid = sid, + smallIconResourceId = resourceIds.smallIconResourceId, + colorResourceId = resourceIds.colorResourceId, + collapseId = notificationMethod.collapseId, + operation = notificationMethod.operation.name, + actions = actions, + defaultAction = defaultAction, + inapp = inapp ) }