Im trying to get back my register ID from the gcm server using the push Notification plugin(ngCordova):
http://ngcordova.com/docs/plugins/pushNotifications/.
here is my code:
var androidConfig = {
"senderID": "900683315534",
"ecb":"notificationReceived"
};
document.addEventListener("deviceready", function(){
console.log('device is ready');
$cordovaPush.register(androidConfig).then(function(result) {
console.log(result);
}, function(err) {
console.log(err);
})
$rootScope.$on('notificationReceived', function(event, notification) {
console.log(notification);
switch(notification.event) {
case 'registered':
if (notification.regid.length > 0 ) {
alert('registration ID = ' + notification.regid);
}
break;
case 'message':
// this is the actual push notification. its format depends on the data model from the push server
alert('message = ' + notification.message + ' msgCount = ' + notification.msgcnt);
break;
case 'error':
alert('GCM error = ' + notification.msg);
break;
default:
alert('An unknown GCM event has occurred');
break;
}
});
}, false);
I am getting this error:
processMessage failed: Message: Jjavascript:notificationReceived({"regid":"APA91bHwMJR8jps-WorB_XyyAx0mzhCopUHFXDcBIcNoEKu0RLCDSf04NV9iob5M1bobrmO21R6HM799NrCv_G_aQdDvTtItgOReC0xvQOu_Tbsyz4AqZECDEhJrK-ozP3t7hnS1H1UZnjM_nuT1_G806wen2RBUKYWRFFtKPwvfjbOHAqN2G88","event":"registered"})
It seems like the my function is not being called. anyone has an idea how can i fix this?