AWS SNS how to add line breaks in message

前端 未结 4 1945
旧时难觅i
旧时难觅i 2021-01-18 20:50

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

aws sns publish --cli-input-json \"{\\\"TopicArn\\\":\\\"xxx\\\",\\\"Message\\\":\\\"first line\\n          


        
相关标签:
4条回答
  • 2021-01-18 21:09

    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:

    aws sns publish --cli-input-json "{\"TopicArn\":\"xxx\",\"Message\":\"first line\\nsecond line\",\"Subject\":\"Empty subject\"}"
    

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

    0 讨论(0)
  • 2021-01-18 21:09

    four backslash works for me

    using Aws SNS with Firebase

    EX: backslashbackslashbackslashbackslash+n

    0 讨论(0)
  • 2021-01-18 21:25

    This worked out for me:

    "first line
second line"
    
    0 讨论(0)
  • 2021-01-18 21:28

    aws sns publish --topic-arn "arn:aws:sns:us-west-2:0123456789012:my-topic" --message file://message.txt

    message.txt is a text file containing the message to publish:

    Hello World Second Line

    Putting the message in a text file allows you to include line breaks .

    0 讨论(0)
提交回复
热议问题