AWS SNS how to add line breaks in message

Question:

I’m trying to send SNS messages via CLI in json format.

But the \n doesn’t work. Neither is “\r\n” or “\n”. I think the string is escaped by SNS so \n doesn’t work. Does anyone know how to send a message of 2 lines?(Sending 2 messages is not an option) Appreciate your advice!

Answer:

I think \\n is actually what you are looking for. I’ve just tested it by sending push notifications to my device through AWS SNS.

So your message should look like this:

Note, you should not leave the white space after the line break symbol, otherwise, your new line would start with that space.

Leave a Reply