在 ios 上使用 GCM 推送通知
Push notification with GCM on ios
我试着按照 Koh 的建议去做 ,我的问题是当我发送这个 JSON 时:
{
"to": "/topics/test",
"data": {
"aps" : {
"alert" : "You got your emails."
}
}
}
但是我收到的通知是:
Notification received: {
aps = "{\"alert\":\"You got your emails.\"}";
"collapse_key" = "do_not_collapse";
from = "/topics/test";
}
似乎JSON aps 在我收到之前被更改为一个简单的字符串。
有没有办法获得正确的通知语法以便我的应用识别它?
您应该使用 "notification" 字段而不是 "data"。
我试着按照 Koh 的建议去做
{
"to": "/topics/test",
"data": {
"aps" : {
"alert" : "You got your emails."
}
}
}
但是我收到的通知是:
Notification received: {
aps = "{\"alert\":\"You got your emails.\"}";
"collapse_key" = "do_not_collapse";
from = "/topics/test";
}
似乎JSON aps 在我收到之前被更改为一个简单的字符串。 有没有办法获得正确的通知语法以便我的应用识别它?
您应该使用 "notification" 字段而不是 "data"。