![](/img/trans.png)
[英]Ionic push notifications how to trigger onNotification event if app is in the background?
[英]ionic framework 2.0 push notifications on event not found
我真的很難為我的Ionic應用程序添加推送通知支持。 我當前的問題與文檔有關,該文檔指出我需要添加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
屬性未找到錯誤。 如何解決此問題?
沒錯 瀏覽器輸出this.push.on
不是函數。 可能與瀏覽器不支持Push
及其本機功能有關。
但是,在移動應用程序中使用它會很好。 如果您想使錯誤消失,因為它令人困惑,則可以檢查用戶當前所處的操作系統,或者檢查他是否具有cordova。
這可以通過包裝你做push.on
的if(this.platform.is('cordova')){}
或者if(platform.is('cordova'))
不能確定this.
來源): 如何檢測我是否在Ionic 2中處於瀏覽器(本地開發)中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.