1
I’m doing an Ionic project to receive notifications (android) and I’m using the phonegap-plugin-push plugin.
var push = PushNotification.init({ "android": {"senderID": "860498722229", icon : "icon"},
"ios": {"alert": "true", "badge": "true", "sound": "true"}, "windows": {} } );
push.on('registration', function(data) {
console.log(data);
$rootScope.id = data.registrationId;
$rootScope.$apply();
});
push.on('notification', function(data) {
alert('Notificação acionada, agora deve-se implementar a navegação no app de acordo com os dados: ' + JSON.stringify(data));
});
push.on('error', function(e) {
alert('registration error: ' + e.message);
});
Yes, I already ran the command that adds the plugin to the 'Ionic add phonegap-plugin-push project'
Always returns the 'Pushnotification' error is not defined.
" 'Pushnotification' is not defined" means that the reference to Pushnotification is not defined. You probably forgot to import javascript from it on your page.
– wryel
vc left this code inside $ionicPlatform.ready(Function () { }); ? It must run inside the ready
– André Vicente