通过 AWS Java SDK 为 iOS 发送带有声音的 SNS (AWS) 消息应该是什么 Json 字符串?
What Json string should it be to send SNS (AWS) message for iOS with sound by AWS Java SDK?
我完全崩溃了。我有代码发送 iOS 的 SNS (AWS) 行:
PublishRequest publishRequest = new PublishRequest("arn:aws:sns:us-east-1:my:topic", messageBody);
当我经过 Json 时它工作正常:
{"message": "ldjldkjlk"}
但是我当然需要声音来通知我,但对我来说没有任何用处。我尝试使用 Json ,当我将它传递给 SNS GUI 时它会起作用,就像这样:
{"message": {
"default": "HERE IS AN ALERT, BADGE, and SOUND",
"APNS_SANDBOX": "{\"aps\": {\"alert\":\"HERE IS AN ALERT, BADGE, and SOUND!\",\"badge\": 1,\"sound\":\"bingbong.aiff\"}}"
}}
但我得到错误:
{"timestamp":1435334944602,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read JSON: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: java.io.PushbackInputStream@2db14d22; line: 1, column: 15]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: java.io.PushbackInputStream@2db14d22; line: 1, column: 15]","path":"/sns/send"}
他们对 PublishRequest 做了什么?我应该在那里传递什么?
如果有人帮助我,那就太棒了!
天哪,我自己找到了答案应该是这样的:
String message = "{\"apn\": { \n" +
" \"default\": \"HERE IS AN ALERT, BADGE, and SOUND\",\n" +
" \"APNS_SANDBOX\": \"{\\"aps\\": {\\"alert\\":\\"HERE IS AN ALERT, BADGE, and SOUND!\\",\\"badge\\": 1,\\"sound\\":\\"bingbong.aiff\\"}}\"\n" +
"}}";
publishRequest.setMessage(message);
publishRequest.setMessageStructure("json");
我完全崩溃了。我有代码发送 iOS 的 SNS (AWS) 行:
PublishRequest publishRequest = new PublishRequest("arn:aws:sns:us-east-1:my:topic", messageBody);
当我经过 Json 时它工作正常:
{"message": "ldjldkjlk"}
但是我当然需要声音来通知我,但对我来说没有任何用处。我尝试使用 Json ,当我将它传递给 SNS GUI 时它会起作用,就像这样:
{"message": {
"default": "HERE IS AN ALERT, BADGE, and SOUND",
"APNS_SANDBOX": "{\"aps\": {\"alert\":\"HERE IS AN ALERT, BADGE, and SOUND!\",\"badge\": 1,\"sound\":\"bingbong.aiff\"}}"
}}
但我得到错误:
{"timestamp":1435334944602,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read JSON: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: java.io.PushbackInputStream@2db14d22; line: 1, column: 15]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: java.io.PushbackInputStream@2db14d22; line: 1, column: 15]","path":"/sns/send"}
他们对 PublishRequest 做了什么?我应该在那里传递什么? 如果有人帮助我,那就太棒了!
天哪,我自己找到了答案应该是这样的:
String message = "{\"apn\": { \n" +
" \"default\": \"HERE IS AN ALERT, BADGE, and SOUND\",\n" +
" \"APNS_SANDBOX\": \"{\\"aps\\": {\\"alert\\":\\"HERE IS AN ALERT, BADGE, and SOUND!\\",\\"badge\\": 1,\\"sound\\":\\"bingbong.aiff\\"}}\"\n" +
"}}";
publishRequest.setMessage(message);
publishRequest.setMessageStructure("json");