Showing posts with label push notifications. Show all posts
Showing posts with label push notifications. Show all posts

Sunday, June 12, 2016

iOS push notifications with sound from Amazon SNS

When sending push notifications from Amazon SNS, to iOS endpoints, with the default JSON format, they are received without sound.
The default format would look like this:
{
  "default" : "Message"
}

In order to get sound for push notifications on iOS, the JSON payload should look like this:
{
  "default" : "Message",
  { "APNS":"{\"aps\":{\"alert\":{\"loc-key\":\"%@\", \"loc-args\":[\"Message\"]}, \"sound\":\"default\"} }" }
}

Why does the payload look like this? I have no idea. The point is that it works at the moment this article was written. I've found it somewhere on stackoverflow, but I can't find it again, so I'm just posting it here for whomever needs this information.

Tuesday, June 16, 2015

Integration with Amazon SNS for push notifications

Pseudocode for Android integration with Amazon SNS:
server call to register for push notifications with registration token and DeviceId
if DeviceId is already stored then
    call DeleteEndpoint
else
    call CreatePlatformEndpoint to create new ARN for this device 
    store new ARN, Token and DeviceId
endif
I know there are other algorithms for working with Amazon’s SNS (like this one) but this seems to be the simplest, and it also solves the problem with Amazon not disabling the ARNs when applications are re-installed.
This should work for iOS-SNS integration, but I haven't had the chance to test.