0

我被难住了。此处是 Phonegap/Mobile Dev 新手。寻求一些建议。

我有一个为 Android 和 iOS 开发的 phonegap 应用程序(带有推送插件)。我试图在 Android 上测试推送通知。我有以下流程

  1. 设备向 GCM(或 APNS)注册并将令牌发送回服务器。
  2. 在服务器端,我确定用户的身份并在 PubNub 上为他们创建一个频道。
  3. 服务器将设备连同频道一起注册到 PubNub。
  4. 我可以验证该设备已订阅了几个频道。
  5. 我从服务器端发送消息。
  6. 我在 PubNub 控制台中看到它。
  7. 但Android上没有通知。

当我尝试使用其中一项免费服务(在小提琴上找到一些 php 代码)来尝试向设备发送消息时,它可以工作。我在设备上看到通知。

我尝试直接从 PubNub 控制台发送消息,但没有成功。

{
"pn_apns": {
    "aps" : {
        "alert": "Game update 49ers touchdown",
        "badge": 2
    },
    "teams" : ["49ers", "raiders"],
    "score" : [7, 0]
},
"pn_gcm": {
    "data" : {
        "summary": "Game update 49ers touchdown",
        "teams" : ["49ers", "raiders"],
        "score" : [7, 0],
        "lastplay" : "5yd run up the middle"
    }
},
"full_game" : {
    "date" : "2014.05.20",
    "background" : "Data that is not pertinent to devices"
},"pn_debug": true
}

注 1 - 我已经在 PubNub 上添加了 GCM API 密钥。注 2 - 我使用的是免费套餐

所以,我想,也许 PubNub 出了点问题,我转向 Parse。

我通过 curl(REST) 创建频道、注册设备和发送消息。我在解析仪表板上看到推送通知,但设备上仍然没有消息。

我还没有在 iOS 上进行测试(处理其他一些与 iOS 相关的问题)。

我已按照 PubNub 和 Parse 的教程进行操作。此时,我想知道设备本身是否需要订阅 PubNub/Parse 并且不能使用后端服务来订阅它们。

请帮忙。

4

0 回答 0