Search in sources :

Example 1 with CoreNotificationHandler

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

the class NotificationHandlerResolverTest method should_get_core_notification_handler_when_no_handlers_in_manifest.

@Test
public void should_get_core_notification_handler_when_no_handlers_in_manifest() throws InterruptedException {
    // Given
    given(moduleLoaderMock.loadModules(eq(NotificationHandler.class))).willReturn(new HashMap<String, NotificationHandler>());
    MobileMessagingCore givenCore = new MobileMessagingCore(context, new AndroidBroadcaster(context), Executors.newSingleThreadExecutor(), moduleLoaderMock);
    // When
    NotificationHandler notificationHandler = givenCore.getNotificationHandler();
    // Then
    assertTrue(notificationHandler instanceof CoreNotificationHandler);
}
Also used : CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) MockNotificationHandler(org.infobip.mobile.messaging.notification.MockNotificationHandler) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) AndroidBroadcaster(org.infobip.mobile.messaging.platform.AndroidBroadcaster) Test(org.junit.Test)

Example 2 with CoreNotificationHandler

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

the class InteractiveNotificationHandler method displayNotification.

@Override
public void displayNotification(Message message) {
    if (context == null)
        return;
    CoreNotificationHandler notificationHandler = new CoreNotificationHandler();
    notificationHandler.setContext(context);
    int notificationId = notificationHandler.getNotificationId(message);
    NotificationCompat.Builder builder = getNotificationBuilder(message, notificationHandler, notificationId);
    notificationHandler.displayNotification(builder, message, notificationId);
}
Also used : CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) NotificationCompat(android.support.v4.app.NotificationCompat)

Example 3 with CoreNotificationHandler

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

the class NotificationHandlerResolverTest method should_get_test_notification_handler.

@Test
public void should_get_test_notification_handler() throws InterruptedException {
    // Given
    given(moduleLoaderMock.loadModules(eq(NotificationHandler.class))).willReturn(new HashMap<String, NotificationHandler>() {

        {
            put(MockNotificationHandler.class.getName(), new MockNotificationHandler());
        }
    });
    MobileMessagingCore givenCore = new MobileMessagingCore(context, new AndroidBroadcaster(context), Executors.newSingleThreadExecutor(), moduleLoaderMock);
    // When
    NotificationHandler notificationHandler = givenCore.getNotificationHandler();
    // Then
    assertFalse(notificationHandler instanceof CoreNotificationHandler);
    assertTrue(notificationHandler instanceof MockNotificationHandler);
}
Also used : CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) MockNotificationHandler(org.infobip.mobile.messaging.notification.MockNotificationHandler) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) AndroidBroadcaster(org.infobip.mobile.messaging.platform.AndroidBroadcaster) MockNotificationHandler(org.infobip.mobile.messaging.notification.MockNotificationHandler) Test(org.junit.Test)

Example 4 with CoreNotificationHandler

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

the class MobileMessagingCore method loadNotificationHandler.

private NotificationHandler loadNotificationHandler() {
    Map<String, NotificationHandler> handlers = moduleLoader.loadModules(NotificationHandler.class);
    NotificationHandler handler;
    if (!handlers.isEmpty()) {
        handler = handlers.values().iterator().next();
    } else {
        handler = new CoreNotificationHandler();
    }
    handler.setContext(context);
    return handler;
}
Also used : CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler)

Aggregations

CoreNotificationHandler (org.infobip.mobile.messaging.notification.CoreNotificationHandler)4 NotificationHandler (org.infobip.mobile.messaging.notification.NotificationHandler)3 MockNotificationHandler (org.infobip.mobile.messaging.notification.MockNotificationHandler)2 AndroidBroadcaster (org.infobip.mobile.messaging.platform.AndroidBroadcaster)2 Test (org.junit.Test)2 NotificationCompat (android.support.v4.app.NotificationCompat)1