use of org.infobip.mobile.messaging.platform.AndroidBroadcaster 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);
}
use of org.infobip.mobile.messaging.platform.AndroidBroadcaster 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);
}
use of org.infobip.mobile.messaging.platform.AndroidBroadcaster in project mobile-messaging-sdk-android by infobip.
the class MobileMessagingGcmIntentService method mobileMessageHandler.
private MobileMessageHandler mobileMessageHandler() {
if (mobileMessageHandler == null) {
MobileMessagingCore mobileMessagingCore = MobileMessagingCore.getInstance(this);
NotificationHandler notificationHandler = mobileMessagingCore.getNotificationHandler();
mobileMessageHandler = new MobileMessageHandler(mobileMessagingCore, new AndroidBroadcaster(this), notificationHandler, mobileMessagingCore.getMessageStoreWrapper());
}
return mobileMessageHandler;
}
use of org.infobip.mobile.messaging.platform.AndroidBroadcaster in project mobile-messaging-sdk-android by infobip.
the class RegistrationTokenHandler method handleRegistrationTokenUpdate.
void handleRegistrationTokenUpdate(Context context) {
String senderId = MobileMessagingCore.getGcmSenderId(context);
if (StringUtils.isBlank(senderId)) {
return;
}
try {
InstanceID instanceID = InstanceID.getInstance(context);
String token = instanceID.getToken(senderId, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
MobileMessagingLogger.v(MobileMessagingLogger.TAG, "RECEIVED TOKEN", token);
new AndroidBroadcaster(context).registrationAcquired(token);
sendRegistrationToServer(context, token);
subscribeTopics(context, token);
} catch (IOException e) {
MobileMessagingLogger.e(InternalSdkError.ERROR_TOKEN_REFRESH.get(), e);
}
}
Aggregations