Skip to content

Instantly share code, notes, and snippets.

@chimmelb
Last active July 30, 2018 13:44
Show Gist options
  • Save chimmelb/f4f31274994e208209407250e2203ba6 to your computer and use it in GitHub Desktop.
Save chimmelb/f4f31274994e208209407250e2203ba6 to your computer and use it in GitHub Desktop.
JSON Data to AWS SNS publish
//text, topicArn, and api.aws.sns all defined elsewhere in scope
var apnsMessage = JSON.stringify({
aps: {
alert: text,
extraData: 'thing'
}
});
var gcmMessage = JSON.stringify({
data: {
message: text,
extraData: 'thing'
}
});
return api.aws.sns.publishAsync({
TopicArn: topicArn,
MessageStructure: 'json',
//use the AWS SNS console to publish a test message see this format
Message: JSON.stringify({
default: text,
APNS: apnsMessage,
APNS_SANDBOX: apnsMessage,
GCM: gcmMessage
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment