我正在使用带有 ngCordova 的推送插件,当 Android 应用程序处于前台时,我没有收到任何 pushNotificationReceived 事件。当我进行设备注册时会触发该事件,并且它似乎也适用于 iOS - 当应用程序处于前台时,它仅在 Android 上。
当应用程序在后台时,我可以毫无问题地获得标准推送通知横幅,但单击横幅也不会触发 pushNotificationReceived。
angular.module('my.controllers', [])
.controller('AppCtrl',function ($scope, $ionicModal, $state, $q, UserService, $cordovaPush) {
$scope.$on('pushNotificationReceived', function (event, notification) {
//this never gets called on Android if the message
//comes in the background through a notification
//this does however get triggered by the push registration event.
alert('notification '+ JSON.stringify(notification));
}
});