【问题标题】:Push notification with GCM on ios在 ios 上使用 GCM 推送通知
【发布时间】:2015-06-10 09:53:22
【问题描述】:

我尝试按照 Koh 建议的 here 做,我的问题是当我发送这个 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 似乎已更改为一个简单的字符串。 有没有办法获得正确的通知语法以便我的应用识别它?

【问题讨论】:

    标签: ios google-cloud-messaging


    【解决方案1】:

    您应该使用“通知”字段而不是“数据”。

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

    【讨论】:

    • 当我这样做时,什么也没有发生。我的意思是,我什至没有通过 [AppDelegate application:didReceiveRemoteNotification:] 方法。
    • 你试过这样吗?: { "notification": { "title": "Portugal vs. Denmark", "body": "5 to 1" }, "to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH- 1RYqx..." }
    • 这工作,这个模型,你能链接到解释它的文档吗?
    • 当然!将其添加到我的答案中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-08
    • 2012-11-27
    • 2016-07-24
    相关资源
    最近更新 更多