SyntaxHighlighter

Tuesday, July 12, 2016

AWS SNS.publish Extended Message Data

Using AWS SNS in NodeJS to send Push Notifications, and we wanted to append extra data to the payloads. AWS has good docs for the plain text message, but trying to use a JSON Message object in the sns.publish call saw an error like:

016-07-12T16:19:09.713Z - error: InvalidParameterType: Expected params.Message to be a string

After some searching, I found the answer in an AWS forum dated back to 2013. Thought I would repost here for easier reference to myself.



The trick was those extra JSON.stringify calls, once to turn the platform messages into strings, and once to turn the entire Message object into a string. Seems like some odd parsing, but I have received notifications on an Android phone, so at least GCM likes it.

11 comments:

  1. This is one awesome blog article. Much thanks again. AWS Online course Bangalore

    ReplyDelete
  2. thank you for providing useful information AWS Online Course

    ReplyDelete
  3. Nice blog. Thank you for sharing such useful post. Keep posting
    Amazon web Services Course in Gurgaon

    ReplyDelete
  4. Give each cup everyone conference. Detail similar movie goal painting firm red. Fine impact language value crime administration no. Machine western purpose course.latest news headlines

    ReplyDelete