Having trouble with push notifications through the ngCordova plugin. Followed the sample code from
(with a slight change - no deviceready listener, code inside ionicPlatform.ready listener)
Below is the code snippet:
angular.module('myApp', ['ionic', 'ngCordova'])
.run(function($ionicPlatform, $rootScope, $state, $cordovaPush) {
$ionicPlatform.ready(function() {
var config = {
"senderID": "myID100001000"
};
$cordovaPush.register(config).then(function(result) {
alert(result);
}, function(err) {
alert(err);
})
});
$rootScope.$on('$cordovaPush:notificationReceived', function(event, notification) {
switch(notification.event) {
case 'registered':
if (notification.regid.length > 0 ) {
alert('registration ID = ' + notification.regid);
}
break;
default:
alert('An unknown GCM event has occurred');
break;
}
});
})
Upon app start, the "OK" alert shows up confirming successful $cordovaPush.register call. Expected a "registered" notification event right after but never received it.
Seeking assistance. Much appreciated!