【问题标题】:Phonegap push notifications get device IDPhonegap 推送通知获取设备 ID
【发布时间】:2015-09-04 13:06:18
【问题描述】:

我正在使用 Phonegap 5.0 和 phonegap-plugin-push 尝试使推送通知工作。

到目前为止我的 js 代码是这样的:

document.addEventListener("deviceready", function () {

    var push = PushNotification.init({ "android": {"senderID": "mySenderId"},
    "ios": {}, "windows": {} } );
    console.log(push);

    push.on('registration', function(data) {
        console.log("registration", data);
    });

    push.on('notification', function(data) {
        console.log("notification", data);
    });

    push.on('error', function(e) {
        console.log("error", e);
    });
});

没有错误,我希望看到某个事件何时发生,但我只看到一个console.log - 这个是“push”对象,我看到的是PushNotification 对象,但其余的什么都没有。

我应该如何让它“询问”谷歌设备 ID?

编辑:我觉得这也应该在模拟器上工作,但事实并非如此。当我在实际设备上运行它时,它工作正常。有没有办法让它在模拟器中工作?

【问题讨论】:

  • 运气好吗?我也遇到了同样的问题
  • 到目前为止,我唯一的解决方案是在真实设备上运行应用程序。

标签: javascript cordova phonegap-plugins phonegap-pushplugin


【解决方案1】:

请确保您正确分配了您的发件人ID。在我看来,代码中没有错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-14
    • 1970-01-01
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 2016-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多