use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class NotificationTapReceiverTest method test_should_not_send_seen_report_message_ids_when_seen_on_tap_disabled.
@Test
public void test_should_not_send_seen_report_message_ids_when_seen_on_tap_disabled() {
// Given
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.MARK_SEEN_ON_NOTIFICATION_TAP, false);
Message givenMessage = createMessage(context, "SomeMessageId", false);
Intent givenIntent = givenIntent(givenMessage, notificationSettings.getIntentFlags());
// When
notificationTapReceiver.onReceive(contextMock, givenIntent);
// Then
Mockito.verify(mobileMessagingCore, Mockito.never()).setMessagesSeen(Mockito.any(String[].class));
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class NotificationTapReceiverTest method test_should_send_notification_tapped_event.
@Test
public void test_should_send_notification_tapped_event() throws Exception {
// Given
Message givenMessage = createMessage(context, "SomeMessageId", false);
Intent givenIntent = givenIntent(givenMessage, notificationSettings.getIntentFlags());
// When
notificationTapReceiver.onReceive(contextMock, givenIntent);
// Then
Mockito.verify(broadcastSender, Mockito.times(1)).notificationTapped(messageArgumentCaptor.capture());
assertJEquals(givenMessage, messageArgumentCaptor.getValue());
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class MobileInteractiveImpl method messageFor.
private Message messageFor(final String categoryId, final NotificationAction action, final Message initialMessage) {
Message message = new Message();
message.setBody(categoryId + " " + action.getId());
HashMap<String, String> map = new HashMap<>();
map.put("initialMessageId", initialMessage.getMessageId());
message.setInternalData(InternalDataMapper.mergeExistingInternalDataWithAnythingToJson(initialMessage.getInternalData(), map));
return message;
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class NotificationActionTapReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
Bundle actionBundle = intent.getBundleExtra(EXTRA_TAPPED_ACTION);
Bundle categoryBundle = intent.getBundleExtra(EXTRA_TAPPED_CATEGORY);
int notificationId = intent.getIntExtra(BroadcastParameter.EXTRA_NOTIFICATION_ID, -1);
Bundle messageBundle = intent.getBundleExtra(BroadcastParameter.EXTRA_MESSAGE);
Message message = Message.createFrom(messageBundle);
NotificationCategory notificationCategory = NotificationCategory.createFrom(categoryBundle);
NotificationAction notificationAction = NotificationAction.createFrom(actionBundle);
String inputText = getInputTextFromIntent(intent, notificationAction);
cancelNotification(context, notificationId);
if (message == null) {
MobileMessagingLogger.e("Received no message in NotificationActionTapReceiver");
return;
}
if (notificationAction == null) {
MobileMessagingLogger.e("Received no action in NotificationActionTapReceiver");
return;
}
if (notificationCategory == null) {
MobileMessagingLogger.e("Received no notification category in NotificationActionTapReceiver");
return;
}
if (inputText != null) {
notificationAction.setInputText(inputText);
}
broadcaster(context).notificationActionTapped(message, notificationCategory, notificationAction);
mobileInteractive(context).triggerSdkActionsFor(notificationCategory.getCategoryId(), notificationAction, message);
startCallbackActivity(context, intent, messageBundle, actionBundle, categoryBundle);
}
use of org.infobip.mobile.messaging.Message in project mobile-messaging-sdk-android by infobip.
the class GeoReportHelper method findSignalingMessagesAndAreas.
/**
* Returns map of signaling messages and corresponding areas that match geofence and transition event
*
* @param messageStore message store to look messages for
* @param requestIds requestIds received from Google Location Services during transition event
* @param event transition event type
* @return signaling messages with corresponding areas
*/
@NonNull
public static Map<Message, List<Area>> findSignalingMessagesAndAreas(Context context, MessageStore messageStore, Set<String> requestIds, @NonNull GeoEventType event) {
Date now = Time.date();
Map<Message, List<Area>> messagesAndAreas = new ArrayMap<>();
for (Message message : messageStore.findAll(context)) {
Geo geo = GeoDataMapper.geoFromInternalData(message.getInternalData());
if (geo == null || geo.getAreasList() == null || geo.getAreasList().isEmpty()) {
continue;
}
// don't trigger geo event before start date
Date startDate = geo.getStartDate();
if (startDate != null && startDate.after(now)) {
continue;
}
List<Area> campaignAreas = geo.getAreasList();
List<Area> triggeredAreas = new ArrayList<>();
for (Area area : campaignAreas) {
for (String requestId : requestIds) {
if (!requestId.equalsIgnoreCase(area.getId())) {
continue;
}
if (!GeoNotificationHelper.shouldReportTransition(context, geo, event)) {
continue;
}
triggeredAreas.add(area);
}
}
if (!triggeredAreas.isEmpty()) {
messagesAndAreas.put(message, triggeredAreas);
}
}
return filterOverlappingAreas(messagesAndAreas);
}
Aggregations