Ionic push notifcation error

Asked

Viewed 235 times

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.

  • 1

    " 'Pushnotification' is not defined" means that the reference to Pushnotification is not defined. You probably forgot to import javascript from it on your page.

  • vc left this code inside $ionicPlatform.ready(Function () { }); ? It must run inside the ready

1 answer

2


recommend Onesignal, the site has an example of how to implement, follows exactly what is written just by changing the Key. It is very reliable besides being free.

https://onesignal.com

Browser other questions tagged

You are not signed in. Login or sign up in order to post.