Search in sources :

Example 1 with Message

use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.

the class FCMMessageMapperTest method test_normalMessage_fromJson_withoutNormalData.

public void test_normalMessage_fromJson_withoutNormalData() throws Exception {
    String internalData = "{" + "\"silent\":" + "{" + "\"title\":\"silentTitle\"," + "\"body\":\"silentBody\"," + "\"sound\":\"silentSound\"," + "\"category\":\"silentCategory\"" + "}" + "}";
    Bundle bundle = new Bundle();
    bundle.putString("gcm.notification.e", "1");
    bundle.putString("gcm.notification.messageId", "L+auqUQFlo1yqk2TEakxua/4rc6DmGgm7cM6G0GRQjU=");
    bundle.putString("android.support.content.wakelockid", "11");
    bundle.putString("collapse_key", "org.infobip.mobile.messaging.showcase.dev");
    bundle.putString("internalData", internalData);
    Message message = FCMMessageMapper.fromCloudBundle(bundle);
    assertNotEquals("silentTitle", message.getTitle());
    assertNotEquals("silentBody", message.getBody());
    assertNotEquals("silentSound", message.getSound());
    assertNotEquals("silentCategory", message.getCategory());
}
Also used : Message(org.infobip.mobile.messaging.Message) Bundle(android.os.Bundle)

Example 2 with Message

use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.

the class FCMMessageMapperTest method test_bundleWithAttachments_intoMessageWithContentUrl.

public void test_bundleWithAttachments_intoMessageWithContentUrl() throws Exception {
    String internalData = "{" + "\"atts\" : [{" + "\"url\":\"someUrl\"" + "}]" + "}";
    Bundle bundle = new Bundle();
    bundle.putString("internalData", internalData);
    Message message = FCMMessageMapper.fromCloudBundle(bundle);
    assertEquals("someUrl", message.getContentUrl());
}
Also used : Message(org.infobip.mobile.messaging.Message) Bundle(android.os.Bundle)

Example 3 with Message

use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.

the class FCMMessageMapperTest method test_customData.

public void test_customData() throws Exception {
    String customPayload = "{" + "\"key1\":\"value1\"," + "\"key2\":\"value2\"," + "\"key3\":\"value3\"" + "}";
    Bundle bundle = new Bundle();
    bundle.putString("customPayload", customPayload);
    Message message = FCMMessageMapper.fromCloudBundle(bundle);
    JSONAssert.assertEquals(customPayload, message.getCustomPayload(), true);
}
Also used : Message(org.infobip.mobile.messaging.Message) Bundle(android.os.Bundle)

Example 4 with Message

use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.

the class FCMMessageMapperTest method test_normalMessage_fromJson_withNormalData.

public void test_normalMessage_fromJson_withNormalData() throws Exception {
    String internalData = "{" + "\"silent\":" + "{" + "\"title\":\"silentTitle\"," + "\"body\":\"silentBody\"," + "\"sound\":\"silentSound\"," + "\"category\":\"silentCategory\"" + "}" + "}";
    Bundle bundle = new Bundle();
    bundle.putString("gcm.notification.e", "1");
    bundle.putString("gcm.notification.messageId", "L+auqUQFlo1yqk2TEakxua/4rc6DmGgm7cM6G0GRQjU=");
    bundle.putString("android.support.content.wakelockid", "11");
    bundle.putString("collapse_key", "org.infobip.mobile.messaging.showcase.dev");
    bundle.putString("gcm.notification.title", "notSilentTitle");
    bundle.putString("gcm.notification.body", "notSilentBody");
    bundle.putString("gcm.notification.sound", "notSilentSound");
    bundle.putString("gcm.notification.category", "notSilentCategory");
    bundle.putString("internalData", internalData);
    Message message = FCMMessageMapper.fromCloudBundle(bundle);
    assertEquals("notSilentTitle", message.getTitle());
    assertEquals("notSilentBody", message.getBody());
    assertEquals("notSilentSound", message.getSound());
    assertEquals("notSilentCategory", message.getCategory());
}
Also used : Message(org.infobip.mobile.messaging.Message) Bundle(android.os.Bundle)

Example 5 with Message

use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.

the class FCMMessageMapperTest method test_fromBundle_success.

public void test_fromBundle_success() throws Exception {
    Bundle plainBundle = new Bundle();
    plainBundle.putString("gcm.notification.messageId", "1234");
    plainBundle.putString("gcm.notification.sound", "some sound");
    plainBundle.putString("gcm.notification.body", "lala");
    plainBundle.putString("gcm.notification.title", "title");
    plainBundle.putString("from", "from");
    plainBundle.putString("gcm.notification.icon", "some icon");
    plainBundle.putString("gcm.notification.silent", "false");
    Message message = FCMMessageMapper.fromCloudBundle(plainBundle);
    assertEquals(message.getMessageId(), "1234");
    assertEquals(message.getSound(), "some sound");
    assertEquals(message.getBody(), "lala");
    assertEquals(message.getTitle(), "title");
    assertEquals(message.getFrom(), "from");
    assertEquals(message.getIcon(), "some icon");
    assertEquals(message.isSilent(), false);
}
Also used : Message(org.infobip.mobile.messaging.Message) Bundle(android.os.Bundle)

Aggregations

Message (org.infobip.mobile.messaging.Message)87 Test (org.junit.Test)44 Intent (android.content.Intent)13 Bundle (android.os.Bundle)13 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)10 GeoReportingResult (org.infobip.mobile.messaging.geo.report.GeoReportingResult)10 Context (android.content.Context)7 GeoReport (org.infobip.mobile.messaging.geo.report.GeoReport)7 GeoTransition (org.infobip.mobile.messaging.geo.transition.GeoTransition)7 JSONObject (org.json.JSONObject)7 List (java.util.List)6 EventReportResponse (org.infobip.mobile.messaging.api.geo.EventReportResponse)6 Geo (org.infobip.mobile.messaging.geo.Geo)6 Map (java.util.Map)5 MoMessage (org.infobip.mobile.messaging.api.messages.MoMessage)5 Area (org.infobip.mobile.messaging.geo.Area)5 NotificationAction (org.infobip.mobile.messaging.interactive.NotificationAction)5 NotificationCategory (org.infobip.mobile.messaging.interactive.NotificationCategory)5 Date (java.util.Date)4