Pubnub GCM通知未被推送Javascript

时间:2016-07-29 00:24:18

标签: javascript push-notification google-cloud-messaging apple-push-notifications pubnub

我目前有以下代码适用于iOS-APNS,但不适用于Android:

function makeMessageNew() {
  var pubnub = new PubNub({
      publishKey : 'pub',
      subscribeKey : 'sub'
  })
  var pushPayload = {
    "pn_apns": {
        "aps" : {
            "alert": "This is a notification",
            "badge": 2,
            "sound": "melody"
        },
    },
    "pn_gcm": {
        "data" : {
            "title":"Hello",
            "message":"This is a notification"
        }
    },
    "pn_debug":true
  }
  pubnub.publish({ message: pushPayload, channel:"channel" }, function (status) {
      console.log(pushPayload);
      console.log(status);
  })
}

在我的Channel-pndebug中,它告诉我:

  

“推送通知apns的设备:2 gcm:1 mpns:0”

我知道我的设备已注册到频道,我之前发送了通知,这意味着我的密钥等是正确的。

然而,即使该通知适用于iOS,并且我收到它,它也不会出现在Android-GCM上。谁能告诉我为什么?

这是我的有效载荷数据:

{
  "pn_apns": {
    "aps": {
      "alert": "This is a notification",
      "badge": 1
    },
    "sound": "melody"
  },
  "pn_gcm": {
    "data": {
      "title": "Push Demo",
      "message": "This is a notification"
    }
  },
  "pn_debug": true
}

0 个答案:

没有答案