use of org.infobip.mobile.messaging.NotificationSettings in project mobile-messaging-sdk-android by infobip.
the class NotificationTapReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
Bundle messageBundle = intent.getBundleExtra(BroadcastParameter.EXTRA_MESSAGE);
Message message = Message.createFrom(messageBundle);
if (message == null) {
MobileMessagingLogger.e("Received no message in NotificationTapReceiver");
return;
}
broadcaster(context).notificationTapped(message);
NotificationSettings notificationSettings = mobileMessagingCore(context).getNotificationSettings();
if (notificationSettings == null) {
return;
}
if (notificationSettings.markSeenOnTap()) {
mobileMessagingCore(context).setMessagesSeen(message.getMessageId());
}
Class callbackActivity = notificationSettings.getCallbackActivity();
if (callbackActivity == null) {
MobileMessagingLogger.e("Callback activity is not set, cannot proceed");
return;
}
int intentFlags = intent.getIntExtra(MobileMessagingProperty.EXTRA_INTENT_FLAGS.getKey(), (Integer) MobileMessagingProperty.INTENT_FLAGS.getDefaultValue());
Intent callbackIntent = new Intent(context, callbackActivity);
callbackIntent.setAction(Event.NOTIFICATION_TAPPED.getKey());
callbackIntent.putExtra(BroadcastParameter.EXTRA_MESSAGE, messageBundle);
// FLAG_ACTIVITY_NEW_TASK has to be here
// because we're starting activity outside of activity context
callbackIntent.addFlags(intentFlags | Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(callbackIntent);
}
Aggregations