Last active
July 30, 2018 13:44
-
-
Save chimmelb/f4f31274994e208209407250e2203ba6 to your computer and use it in GitHub Desktop.
JSON Data to AWS SNS publish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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