vendredi 7 août 2015

Sending a notification-only payload to GCM using AWS SNS

I am trying to send mobile push notifications to GCM via AWS SNS. According to the latest GCM 3.0 documentation, one may include either a "notification" payload or a "data" payload (or both). If you send a notification payload, then GCM will take care of showing the notification on the end-user device for you.

Using the Amazon SNS Console, I tried sending a notification-only payload, but I encountered the following error:

Invalid parameter: Message Reason: Invalid notification for protocol GCM: data key is expected in the json message (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter)

I'm sending:

{
  "GCM":"{\"notification\":{\"title\":\"Test Message\"}}"
}

I suspect this might be an issue with SNS still conforming to a previous version of GCM and therefore it expects a "data" key, but I'm not sure. Is anyone else having a similar problem or have any experience with this? Thanks!




Aucun commentaire:

Enregistrer un commentaire