Skip to content

Push Notification Data

Push Notification AppEventData is accessible via ClientAPI.getAppEventData() API when you are in the handler of Push Events such as OnReceiveFetchCompletion and OnReceiveNotificationResponse. It contains the title, body, badge and additional data property of the push notification.

Structure of Push Notification's AppEventData

Unified Property Name iOS Source Property Android Source Property Description
title payload.aps.alert.title payload.notification.title If the payload contains title-loc-key (iOS) or titleLocKey (Android), then this property will contain the localized title text
body payload.aps.alert.body payload.notification.body If the payload contains loc-key (iOS) or bodyLocKey (Android), then this property will contain the localized body text
badge payload.aps.badge payload.data.badgepayload.data.badge
data payload.aps.data payload.data.data This property contains a JSON object for any custom data you can for processing the notification
payload payload payload This property contains the raw notification payload, so that you can still access platform-specific properties and also maintain backward compatibility

On Android device, title and body are available in OnReceiveForegroundNotification event only. In the OnReceiveNotificationResponse and OnReceiveFetchCompletion, they will always be null.

Note

Remove title and body from the request, if you want to send localizable push notification.

Request Example

An example of a push request to be sent to SAP Mobile Service:

{
  "alert": "{ //<--- THIS IS FOR iOS
    // \"title\" : \"Non-Localized Title\",
    // \"body\":\"Non-Localized Body\",
    \"loc-key\" : \"localized_body\",
    \"loc-args\" : [ \"Jenna\",\"Frank\",\"MDK\"],
    \"title-loc-key\" :\"localized_title\",
    \"title-loc-args\": [\"123\"]
  }",
  "badge": 1,
  "data": "{\"ObjectType\":\"MyWorkOrder\",\"ObjectID\":\"123456\"}",
  "gcmNotification": { // <--- THIS IS FOR ANDROID
    // "title": "Non-Localized Title",
    // "body": "Non-Localized Body",
    "sound": "OverrideSound",
    "bodyLocKey": "localized_body",
    "bodyLocArgs": "[\"Jenna\",\"Frank\",\"MDK\"]",
    "titleLocKey": "localized_title",
    "titleLocArgs": "[\"123\"]"
  }
}

Note

For more details of the request properties see Native Provider Notification Handling

If you sent this request, then below are the example of the payload in the AppEventData for each platforms.

AppEventData Example in iOS

This is the content of AppEventData that the app will receive in iOS

{
  "badge": 1,
  "title": "Localized Title 123",
  "body": "Jenna and Frank are required for MDK development.",
  "data": {
    "ObjectType": "MyWorkOrder",
    "ObjectID": "123456"
  },
  "payload": {
    "aps": {
      "alert": {
        "loc-args": ["Jenna", "Frank", "MDK"],
        "title": "Localized Title 123",
        "title-loc-args": ["123"],
        "title-loc-key": "localized_title",
        "body": "Jenna and Frank are required for MDK development.",
        "loc-key": "localized_body"
      },
      "badge": 1
    },
    "data": "{\"ObjectType\":\"MyWorkOrder\",\"ObjectID\":\"123456\"}",
    "mobileservices.notificationId": "xx"
  }
}

"AppEventData" Example in Android

This is the content of AppEventData that the app will receive in Android

{
  "badge": 1,
  "title": "Localized Title 123",
  "body": "Jenna and Frank are required for MDK development.",
  "data": {
    "ObjectType": "MyWorkOrder",
    "ObjectID": "123456"
  },
  "payload": {
    "notification": {
      "body": null,
      "bodyLocArgs": ["Jenna","Frank","MDK"],
      "bodyLocKey": "localized_body",
      "title": null,
      "titleLocArgs": ["123"],
      "titleLocKey": "localized_title"
    },
    "data": {
      "badge": "1",
      "cdata": "{\"ObjectType\":\"MyWorkOrder\",\"ObjectID\":\"123456\"}",
      "data": "{\"ObjectType\":\"MyWorkOrder\",\"ObjectID\":\"123456\"}",
      "ObjectType": "MyWorkOrder",
      "ObjectID": "123456",
      "alert": "{\"body\":\"Non-Localized Body\",\"loc-key\" : \"localized_body\",\"loc-args\" : [ \"Jenna\",\"Frank\",\"MDK\"],\"title\" : \"Non-Localized Title\",\"title-loc-key\" :\"localized_title\",\"title-loc-args\": [\"123\"]}",
      "mobileservices.notificationId": "xxxx"
    }
  }
}

Last update: August 12, 2020