我真的很难为我的 Ionic 应用程序添加推送通知支持。我当前的问题与 documentation 有关,其中指出我需要添加一个 cordova 推送插件(我有),然后添加以下事件处理程序:
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
property not found 错误。我该如何解决这个问题?
最佳答案
没错。浏览器输出 this.push.on
不是函数。可能与不支持 Push
及其 native 功能的浏览器有关。
但是,在您的移动应用程序中使用它就可以正常工作。如果你想让错误消失,因为它令人困惑,你可以检查用户当前使用的是哪个操作系统,或者检查他是否有 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
关于ios - ionic framework 2.0 事件推送通知未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41855058/