【发布时间】:2017-06-15 09:12:22
【问题描述】:
我正在使用cordova插件添加phonegap-plugin-push插件来推送通知 在前台通知工作正常。我也可以处理事件。 当我的应用程序在后台时,我也会收到通知,但是单击推送通知时,我的事件不会触发。 我正在使用以下代码
$cordovaPushV5.initialize(options).then(function() {
// start listening for new notifications
$cordovaPushV5.onNotification();
// start listening for errors
$cordovaPushV5.onError();
// register to get registrationId
if (PNdeviceToken == null) //becuase registration will be done only the very first
{
$cordovaPushV5.register().then(function(registrationId) {
// save `registrationId` somewhere;
window.localStorage.setItem('PNdeviceToken', registrationId);
$rootScope.fcmToken = registrationId;
console.log(registrationId)
alert("first time registered id -- " + registrationId)
})
} else {
$rootScope.fcmToken = PNdeviceToken;
alert("already saved registered id -- " + $rootScope.fcmToken)
}
});
$rootScope.$on('$cordovaPushV5:notificationReceived', function(event, data) {
console.log(event)
console.log(data)
})
当我点击后台推送通知时 $cordovaPushV5:notificationReceived 事件未触发,我该如何解决这个问题?
如何处理后台推送通知事件?
【问题讨论】:
标签: android cordova ionic-framework