[Firebase Mobile] Push Notifications whilst user has app open bug ?

Forge Component
(19)
Published on 6 Jan by David Sousa
19 votes
Published on 6 Jan by David Sousa

Is there a bug in cloudNotification-> FirebaseCloudMessaging -> NotificationHandler ?



The notification JSON feed to the HandleNotificationData javascript is of the format 

{"gcm.message_id":"1575606863892691","tap":false,"google.c.a.e":"1","aps":{"alert":{"title":"Example Message Title","body":"Example Message Body"}}}



But the Javascript is not drilling into 'aps' and 'alert'


if($parameters.NotificationJSON) {
    var notificationData = JSON.parse($parameters.NotificationJSON);
    $parameters.Title = notificationData.title ? notificationData.title : "";
    $parameters.Body = notificationData.body ? notificationData.body : "";

    $parameters.Deeplink = notificationData.click_action ? notificationData.click_action : "";
    $parameters.AppInBackground = notificationData.tap ? notificationData.tap : false;
       
    var data = extractDataFromNotification(notificationData);
    $parameters.DataKeyValues = JSON.stringify(data);
}


 I've made the change below which looks to work now in our app


if($parameters.NotificationJSON) {
    var notificationData = JSON.parse($parameters.NotificationJSON);
    $parameters.Title = notificationData.aps.alert.title ? notificationData.aps.alert.title : "";
    $parameters.Body = notificationData.aps.alert.body ? notificationData.aps.alert.body : "";

    $parameters.Deeplink = notificationData.click_action ? notificationData.click_action : "";
    $parameters.AppInBackground = notificationData.tap ? notificationData.tap : false;
       
    var data = extractDataFromNotification(notificationData);
    $parameters.DataKeyValues = JSON.stringify(data);
}