Category: apns

Amazon SNS custom platform specific payloads for apns

The SNS documentation explains that you can specify custom payloads per platform, by specifying the platform now. The APNS sandbox and production APNS require different keys.

APNS and APNS_SANDBOX are separate platforms when specifying the payloads. Additional pitfall was that I was specifying the default message, which is automatically converted into {aps: alert: “message” }}, so messages were coming in at the iOS client, but not the ones I was expecting.

Also, the payload for each application must be json, but properly escaped.

##Example payload from the documentation

{
    "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\"} }",
    "GCM": "{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"}}",
    "ADM": "{ \"data\": { \"message\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\" }}"
}

When using APNS in sandbox mode you need to specify APNS_SANDBOX instead of APNS, this is not clear from the documentation as you can see in the example.

The list of Applications in the Console will also make this more clear, see the screenshot below:

Leave a Comment