PushNotificationPayload Class

Contains methods to create the notification message payload for an Apple device.

Messaging

Apple has specific requirements for the notification payload. and this class has helper methods to create the payload. For more information on Apple’s payload parameters, search for “Apple Push Notification Service” at https://developer.apple.com/library/mac/documentation/.

See the Push Notification Example .

The following are the methods for PushNotificationPayload. All are global static methods.

Helper method that creates a valid Apple payload from the specified arguments.

public static Map<String,Object> apple(String alert, String sound, Integer badgeCount, Map<String,Object> userData)

  • alert:

    Type: String

    Notification message to be sent to the mobile client.

  • sound:

    Type: String

    Name of a sound file to be played as an alert. This sound file should be in the mobile application bundle.

  • badgeCount:

    Type: Integer

    Number to display as the badge of the application icon.

  • userData:

    Type: Map<String, Object>

    Map of key-value pairs that contains any additional data used to provide context for the notification. For example, it can contain IDs of the records that caused the notification to be sent. The mobile client app can use these IDs to display these records.

Type: Map<String, Object>

Returns a formatted payload that includes all of the specified arguments.

To generate a valid payload, you must provide a value for at least one of the following parameters: alert, sound, badgeCount.

See the Push Notification Example.

Helper method that creates a valid Apple payload from the specified arguments.

public static Map<String,Object> apple(String alertBody, String actionLocKey, String locKey, String[] locArgs, String launchImage, String sound, Integer badgeCount, Map<String,Object> userData)

  • alertBody:

    Type: String

    Text of the alert message.

  • actionLocKey:

    Type: String

    If a value is specified for the actionLocKey argument, an alert with two buttons is displayed. The value is a key to get a localized string in a Localizable.strings file to use for the right button’s title.

  • locKey:

    Type: String

    Key to an alert-message string in a Localizable.strings file for the current localization.

  • locArgs:

    Type: List <String>

    Variable string values to appear in place of the format specifiers in locKey.

  • launchImage:

    Type: String

    File name of an image file in the application bundle.

  • sound:

    Type: String

    Name of a sound file to be played as an alert. This sound file should be in the mobile application bundle.

  • badgeCount:

    Type: Integer

    Number to display as the badge of the application icon.

  • userData:

    Type: Map <String, Object>

    Map of key-value pairs that contains any additional data used to provide context for the notification. For example, it can contain IDs of the records that caused the notification to be sent. The mobile client app can use these IDs to display these records.

Type: Map <String, Object>

Returns a formatted payload that includes all of the specified arguments.

To generate a valid payload, you must provide a value for at least one of the following parameters: alert, sound, badgeCount.