1

I've implemented Amazon SNS for push notifications.

I'm sending json in the following structure:

{
  "aps":{
    "alert":{
      "loc-args":["ARGS"],
      "loc-key":"KEY",
    }
    "sound":"default"
  }
}

But on iOS client I'm receiving it as escaped string and everything from my message is inside "alert" key

[AnyHashable("aps"): {
   alert = "{\"aps\":{\"alert\":{\"loc-args\":[\"ARGS\"],\"loc-key\":\"KEY\"},\"sound\":\"default\"}";
}]

I've also tried different formats from here http://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-custommessage.html but every-time I'm receiving the same escaped string.

Does anyone had the same problem?

Orest
  • 6,548
  • 10
  • 54
  • 84

1 Answers1

1

So the problem was in publishRequest.setMessageStructure("json"); flag. I've missed it.

Also notification should be sent in the following format:

{"APNS_SANDBOX":"{\"aps\":{\"alert\":{\"loc-args\":[\"ARGS\"],\"loc-key\":\"KEY\"},\"sound\":\"default\"}}
Orest
  • 6,548
  • 10
  • 54
  • 84
  • This small little change, i.e. to use "json" flag finally solved my problem after so many days of searching answer to this problem. I am sending message from Android, meaning Java platform, but I couldn't find this critical piece of information documented anywhere. – zeeshan Sep 01 '20 at 18:12