It is very difficult for me to receive push notifications (using the ngCordova plugin) to work. I executed their sample code exactly as described on the site: http://ngcordova.com/docs/plugins/pushNotifications/
(the only difference is that I don't have a deviceready listener, instead, my code is inside the ionicPlatform.ready listener.)
Here is my code:
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; } }); })
When my application starts, I get an โOKโ warning, so I know that it successfully passes through a call to $ cordovaPush.register. However, I expected to receive a โregisteredโ notice right after, but I never get a notification.
Any help would be appreciated.
javascript angularjs cordova ionic
Prabhu
source share