[英]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");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.