ios - 在 ios 上使用 GCM 推送通知

标签 ios google-cloud-messaging

我尝试按照 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 似乎已更改为简单的字符串。 有没有办法获得正确的通知语法以便我的应用程序识别它?

最佳答案

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

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

关于ios - 在 ios 上使用 GCM 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30752951/

相关文章:

android - 无法实例化 GcmBroadcastReceiver

ios - UITest 无法终止 com.test.abc :3708 after 60. 0s;状态仍然是`Running Foreground

objective-c - 核心数据以编程方式向条目添加属性

Android 客户端到客户端消息传递,无需我自己的 GCM 服务器

安卓无声推送

c# - Azure 通知中心错误 401

objective-c - 获取 CALayer 的圆角内容区域轮廓作为剪切路径

ios - 如何在使用 MPMoviePlayerController 时识别点击手势

android - Cordova 嵌入 Webview 在 native 应用程序上透明

android - GCM - 可能的字符组成 'registration id'