use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class ExpandableListAdapter method getFullMessageText.
private String getFullMessageText(int groupPosition) throws JSONException {
Message m = messages.get(groupPosition);
if (m == null) {
return null;
}
String text = "messageId: " + m.getMessageId();
text += "\ntitle: " + m.getTitle();
text += "\nbody: " + m.getBody();
text += "\nsound: " + m.getSound();
text += "\nvibrate: " + m.isVibrate();
text += "\nicon: " + m.getIcon();
text += "\nsilent: " + m.isSilent();
text += "\ncategory: " + m.getCategory();
text += "\nfrom: " + m.getFrom();
text += "\nreceivedTimestamp: " + m.getReceivedTimestamp();
text += "\nseenTimestamp: " + m.getSeenTimestamp();
if (m.getInternalData() != null) {
text += "\ninternalData: " + new JSONObject(m.getInternalData()).toString(4);
}
if (m.getCustomPayload() != null) {
try {
text += "\ncustomPayload: " + m.getCustomPayload().toString(4);
} catch (JSONException e) {
e.printStackTrace();
}
}
text += "\ndestination: " + m.getDestination();
text += "\nstatus: " + m.getStatus();
text += "\nstatusMessage: " + m.getStatusMessage();
text += "\ncontentUrl: " + m.getContentUrl();
return text;
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class ColoredScreenActivity method onCreate.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_colored_screen);
View layout = findViewById(R.id.rl_screen);
layout.setBackgroundColor(getBackgroundColor());
Message message = Message.createFrom(getIntent().getExtras());
TextView tv = findViewById(R.id.tv_text);
if (message != null) {
tv.setText(message.getBody());
} else {
tv.setText(R.string.no_message_provided);
}
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class GeoAreasHandlerTests method test_should_notify_messages_only_for_active_campaigns.
@Test
public void test_should_notify_messages_only_for_active_campaigns() throws InterruptedException {
// Given
Area area = createArea("areaId1");
Mockito.when(messageStore.findAll(Mockito.any(Context.class))).thenReturn(Arrays.asList(createMessage(context, "signalingMessageId1", "campaignId1", true, area), createMessage(context, "signalingMessageId2", "campaignId2", true, area), createMessage(context, "signalingMessageId3", "campaignId3", true, area)));
EventReportResponse response = new EventReportResponse();
response.setSuspendedCampaignIds(Sets.newSet("campaignId1"));
response.setFinishedCampaignIds(Sets.newSet("campaignId2"));
Mockito.when(geoReporter.reportSync(Mockito.any(GeoReport[].class))).thenReturn(new GeoReportingResult(response));
GeoTransition transition = GeoHelper.createTransition("areaId1");
// When
geoAreasHandler.handleTransition(transition);
// Then
Mockito.verify(geoNotificationHelper, Mockito.times(1)).notifyAboutGeoTransitions(geoNotificationCaptor.capture());
assertEquals(1, geoNotificationCaptor.getValue().size());
Map.Entry<Message, GeoEventType> notification = geoNotificationCaptor.getValue().entrySet().iterator().next();
assertEquals(GeoEventType.entry, notification.getValue());
Message message = notification.getKey();
Geo geo = GeoDataMapper.geoFromInternalData(message.getInternalData());
assertNotNull(geo);
assertNotSame("signalingMessageId3", message.getMessageId());
assertTrue(StringUtils.isNotBlank(message.getMessageId()));
assertEquals("campaignId3", geo.getCampaignId());
assertEquals("areaId1", geo.getAreasList().get(0).getId());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class GeoAreasHandlerTests method test_should_report_transition.
@Test
public void test_should_report_transition() {
// Given
Message m = createMessage(context, "SomeSignalingMessageId", "SomeCampaignId", true, createArea("SomeAreaId"));
Mockito.when(messageStore.findAll(Mockito.any(Context.class))).thenReturn(Collections.singletonList(m));
Mockito.when(geoReporter.reportSync(Mockito.any(GeoReport[].class))).thenReturn(new GeoReportingResult(new Exception()));
GeoTransition transition = GeoHelper.createTransition(123.0, 456.0, "SomeAreaId");
time.set(789);
// When
geoAreasHandler.handleTransition(transition);
// Then
Mockito.verify(geoReporter, Mockito.times(1)).reportSync(geoReportCaptor.capture());
GeoReport report = geoReportCaptor.getValue()[0];
assertEquals("SomeAreaId", report.getArea().getId());
assertEquals("SomeCampaignId", report.getCampaignId());
assertEquals("SomeSignalingMessageId", report.getSignalingMessageId());
assertNotSame("SomeSignalingMessageId", report.getMessageId());
assertTrue(StringUtils.isNotBlank(report.getMessageId()));
assertEquals(789, report.getTimestampOccurred().longValue());
assertEquals(123.0, report.getTriggeringLocation().getLat());
assertEquals(456.0, report.getTriggeringLocation().getLng());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class GeoAreasHandlerTests method test_should_save_messages_with_generated_ids_if_report_unsuccessful.
@Test
public void test_should_save_messages_with_generated_ids_if_report_unsuccessful() {
// Given
Message m = createMessage(context, "SomeSignalingMessageId", "SomeCampaignId", true, createArea("SomeAreaId"));
Mockito.when(messageStore.findAll(Mockito.any(Context.class))).thenReturn(Collections.singletonList(m));
Mockito.when(geoReporter.reportSync(Mockito.any(GeoReport[].class))).thenReturn(new GeoReportingResult(new Exception()));
GeoTransition transition = GeoHelper.createTransition(123.0, 456.0, "SomeAreaId");
time.set(789);
// When
geoAreasHandler.handleTransition(transition);
// Then
Message message = geoAreasHandler.getMobileMessagingCore().getMessageStore().findAll(context).get(0);
Geo geo = GeoDataMapper.geoFromInternalData(message.getInternalData());
assertNotNull(geo);
assertNotSame("SomeSignalingMessageId", message.getMessageId());
assertTrue(StringUtils.isNotBlank(message.getMessageId()));
assertEquals("SomeCampaignId", geo.getCampaignId());
assertEquals(123.0, geo.getTriggeringLatitude());
assertEquals(456.0, geo.getTriggeringLongitude());
assertEquals("SomeAreaId", geo.getAreasList().get(0).getId());
}
Aggregations