in MyNotificationApplication/app/src/main/java/com/example/mynotificationapplication/PushListenerService.java [37:69]
public void onMessageReceived(@NotNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Log.d(TAG, "Message: " + remoteMessage.getData());
final NotificationClient notificationClient = MainActivity.Companion.getPinpointManager(getApplicationContext()).getNotificationClient();
final NotificationDetails notificationDetails = NotificationDetails.builder()
.from(remoteMessage.getFrom())
.mapData(remoteMessage.getData())
.intentAction(NotificationClient.FCM_INTENT_ACTION)
.build();
notificationDetails.setTargetClass(PinpointOverrideNotificationReceiver.class);
NotificationClient.PushResult pushResult = notificationClient.handleNotificationReceived(notificationDetails);
if (!NotificationClient.PushResult.NOT_HANDLED.equals(pushResult)) {
/**
The push message was due to a Pinpoint campaign.
If the app was in the background, a local notification was added
in the notification center. If the app was in the foreground, an
event was recorded indicating the app was in the foreground,
for the demo, we will broadcast the notification to let the main
activity display it in a dialog.
*/
if (NotificationClient.PushResult.APP_IN_FOREGROUND.equals(pushResult)) {
/* Create a message that will display the raw data of the campaign push in a dialog. */
final HashMap<String, String> dataMap = new HashMap<>(remoteMessage.getData());
broadcast(remoteMessage.getFrom(), dataMap);
}
return;
}
}