Amazon Simple Notification Service
Developer Guide

Send Custom, Platform-Specific Payloads to Mobile Devices

You can use the AWS Management Console or Amazon SNS APIs to send custom messages with platform-specific payloads to mobile devices. For information about using the Amazon SNS APIs, see Using Amazon SNS Mobile Push APIs and the SNSMobilePush.java file in snsmobilepush.zip.

JSON-Formatted Message Data

When sending platform-specific payloads, the data must be formatted as JSON key-value pair strings, with the quotation marks escaped. The following examples show a custom message for the FCM platform.

{ "FCM":"{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"}}" }

Platform-Specific Key-Value Pairs

In addition to sending custom data as key-value pairs, you can send platform-specific key-value pairs. The following example shows the inclusion of the FCM parameters time_to_live and collapse_key after the custom data key-value pairs in the FCM data parameter.

{ "FCM":"{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"},\"time_to_live\": 3600,\"collapse_key\":\"deals\"}" }

For a list of the key-value pairs supported by each of the push notification services supported in Amazon SNS, see the following:

Messages to an App on Multiple Platforms

To send a message to an app installed on devices for multiple platforms, such as FCM and APNS, you must first subscribe the mobile endpoints to a topic in Amazon SNS and then publish the message to the topic. The following example shows a message to send to subscribed mobile endpoints on APNS, FCM, and ADM:

{ "default": "This is the default message which must be present when publishing a message to a topic. The default message will only be used if a message is not present for one of the notification platforms.", "APNS": "{\"aps\":{\"alert\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\"} }", "FCM":"{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"}}", "ADM": "{ \"data\": { \"message\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\" }}" }