I am using PushPlugin to handle push notifications. I am able to get device token and receive the notifications but the callback function is not being called. Here’s my service code:
'use strict';
angular.module('ntf.services')
.factory('Notification', function (Device) {
var pushNotification;
var tokenHandler = function(result){
Device.updatePushToken(result);
};
var errorHandler = function(err){
alert('error = ' + err);
};
var onNotification = function(event){
console.log("ON NOTIFICATION: " + JSON.stringify(event))
if ( event.alert )
{
navigator.notification.alert(event.alert);
}
if ( event.sound )
{
...
}
//badge update is handled here...
};
return {
init: function(){
pushNotification = window.plugins.pushNotification;
if (!Device.isPushTokenSet()){
pushNotification.register(
tokenHandler,
errorHandler,
{
"badge": "true",
"sound": "true",
"alert": "true",
"ecb": "onNotification"
}
);
}
}, //init
};//return
});
The ‘onNotification’ above never gets called. What am I missing here?
Thanks