【问题标题】:ionic framework 2.0 push notifications on event not found离子框架 2.0 未找到事件的推送通知
【发布时间】:2017-06-10 20:06:44
【问题描述】:

我真的很难为我的 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 属性未找到错误。我该如何解决这个问题?

【问题讨论】:

    标签: ios ionic-framework ionic2


    【解决方案1】:

    没错。浏览器输出 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

    【讨论】:

    • 使用 this.push.plugin.on 似乎最终为我解决了这个问题!
    • 嗯,我使用this.push.on 也可以,只是控制台中的烦人错误:) 很酷,通过添加.plugin 它可以正常工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多