Android 来自 PubNub、Parse、Amazon SNS 的 GCM 通知失败

Android GCM notifications fail from PubNub, Parse, Amazon SNS

我一直在尝试向 iOS 和 Android 上部署的 Phonegap 应用程序发送推送通知。 iOS 工作正常,但是当我从 PubNub、Parse 和 Amazon SNS 的任何开发控制台发送推送通知时,Android 不起作用。

我确实验证了如果我使用 GCM API 可以发送通知,所以我使用了正确的发件人 ID、API 密钥和设备令牌。

我在 PubNub 控制台上没有看到任何错误。在 Parse 仪表板上,我看到推送通知已发送。 Amazon SNS 上没有错误。然而,设备上没有推送通知。

我没主意了。在此先感谢您提供任何有用的建议。

本教程说明了如何使用 PubNub 配置 Android GCM:http://www.pubnub.com/docs/java/android/tutorial/google-push-notification.html

在 PubNub 的帮助下,找出问题所在。 PubNub 上的示例具有以下格式

{"pn_gcm": {
    "data" : {
        "GCMSays" : "hi" }
    }
}

但要求的格式是

{"pn_gcm": {
        "data" : {
            "message" : "hi" }
        }
 }

确认使用 PubNub 控制台后,我更新了代码中的 JSON 对象,一切都很顺利。

使用 Parse 控制台,我尝试创建一个具有类似格式的 JSON 对象,但没有成功。还没有尝试过 Amazon SNS。

[Parse 开发者] Parse 不为 PhoneGap 提供第一方支持;他们的产品只适用于 JS SDK,不支持原生推送。我描述了让 Parse 识别您的设备以使用任意语言推送的必要条件 in a previous question。但是,您可能会收到推送但不会创建通知。

在 Android 中(与 iOS、WinRT 或 WinPhone 不同),推送并不一定意味着 "notification." 来自 Parse android 的原生 SDK creates this automatically for you. You'll need to create your own BroadcastReceiver and wire it to handle the intents that the Play Store app is sending for pushes. You can find these in our Android Push Tutorial.在您的 BroadcastReceiver 中,您需要在接收推送时创建并注册您自己的 Notification 对象。

对于 Firebase 云消息传递,我必须使用此结构来接收托盘通知:

"pn_gcm": {
    "notification": {
        "title": push_title,
        "text": push_message
    }
},