Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created August 5, 2016 23:00
Show Gist options
  • Save brianleroux/37f9545debc703b23f041a9efb531fc0 to your computer and use it in GitHub Desktop.
Save brianleroux/37f9545debc703b23f041a9efb531fc0 to your computer and use it in GitHub Desktop.
Send a silent push notification to APNS with AWS SNS.
sns.publish({
TargetArn: device.arn,
MessageStructure: 'json',
Message: JSON.stringify({
default: 'you will never see this muah!',
APNS_SANDBOX: JSON.stringify({
aps: {
'alert': '',
'content-available': 1
},
'event-category': eventname
})
})
},
function __notifiedAPNS(err, data) {
console.log(err, JSON.stringify(data, null, 2))
callback()
})
@brianleroux
Copy link
Author

This was quite a struggle to figure out. Hope posting this helps someone else!

@shaase
Copy link

shaase commented Jul 27, 2017

Hey Brian, just wanted to post to let you know it helped me! Thanks for the assistance!

@pktippa
Copy link

pktippa commented Mar 26, 2021

Hey Brian, could you post GCM (Android) variant for silent push notification with AWS SNS also? Thanks.

@AndresCanella
Copy link

I found that the only item in aps should be 'content-available': 1. Adding anything else caused the silent push not to be delivered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment