Medo
Medo

Reputation: 63

Push notification with GCM on ios

I tried to do as Koh suggested here, my problem is that when I send this JSON :

{
    "to": "/topics/test",
    "data": {
        "aps" : {
            "alert" : "You got your emails."
        }
    }
}

But the notification I receive is :

Notification received: {
    aps = "{\"alert\":\"You got your emails.\"}";
    "collapse_key" = "do_not_collapse";
    from = "/topics/test";
}

It seems that the JSON aps is changed to a simple string before I receive it. Is there a way to get the proper notification syntax so that my app recognize it ?

Upvotes: 2

Views: 706

Answers (1)

Artem Aleksandrov
Artem Aleksandrov

Reputation: 352

You should use "notification" field instead of "data".

https://developers.google.com/cloud-messaging/server-ref

Upvotes: 2

Related Questions