简体   繁体   中英

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 ?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM