离子框架2.0推送未找到事件的通知

时间:2017-01-25 15:13:07

标签: ios ionic-framework ionic2

我真的很难为我的Ionic应用程序添加推送通知支持。我当前的问题与documentation有关,它指出我需要添加一个cordova push插件(我有)然后添加以下事件处理程序:

this.push.on('notification', function (data) {
    // do something with the push data
    // then call finish to let the OS know we are done
    push.finish(function () {
        console.log("processing of push data is finished");
    }, function () {
        console.log("something went wrong with push.finish for ID = " + data.additionalData.notId)
    }, data.additionalData.notId);
});

但是,我发现on属性未找到错误。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

这是对的。浏览器输出this.push.on不是函数。可能与不支持Push的浏览器及其本机功能有关。

但是,在您的移动应用程序中使用它可能会很好。如果你想让错误消失,因为它令人困惑,你可以检查用户当前是哪个操作系统,或检查他是否有cordova。

这可以通过将您的push.on包裹在if(this.platform.is('cordova')){}if(platform.is('cordova'))(不确定this.)来源来完成:How to detect if I am in browser (local development) in Ionic 2