[英]What Json string should it be to send SNS (AWS) message for iOS with sound by AWS Java SDK?
I absolutely broke my head. 我绝对打破了我的脑袋。 I have code which send SNS (AWS) for iOS with line:
我有代码,用于发送iOS的SNS(AWS):
PublishRequest publishRequest = new PublishRequest("arn:aws:sns:us-east-1:my:topic", messageBody);
and it works fine when I pass there Json like this: 当我像这样经过Json时,它工作正常:
{"message": "ldjldkjlk"}
But of course I need sound to my notification and nothing is works for me. 但我当然需要声音通知我,没有什么对我有用。 I tried with Json which works when I pass it to SNS GUI, something like that:
我尝试使用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\"}}"
}}
But I get error: 但我得到错误:
{"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"}
What did they do with PublishRequest? 他们用PublishRequest做了什么? What I should pass there?
我应该通过什么? It will be amazing if somebody helps me!
如果有人帮助我会很棒!
OMG I found an answer for myself it should be like this: 天哪,我找到了自己的答案应该是这样的:
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");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.