PushV5 registering but not receiving notifications on iOS


#1

For a while now I’ve been struggling with implementing push notifications into my ionic v1 app. Implementing them in a blank ionic app gives the same result:

I’ve build the blank ionic starter app, added the phonegap-plugin-push plugin and finally the latest version of ngCordova. And change the app.js to this:

angular.module('starter', ['ionic', 'ngCordova'])

.run(function($ionicPlatform, $cordovaPushV5, $rootScope) {
  $ionicPlatform.ready(function() {
    console.log('[+] Ionic ready...')

    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }

    console.log('[+] Ready to init push...')
    $cordovaPushV5.initialize(
        {
            ios: {
                alert: "true",
                badge: "true",
                sound: "true"
            }
        }
    ).then(function (result) {
        console.log('[+] Initialized push...')

        $cordovaPushV5.onNotification();
        $cordovaPushV5.onError();
        $cordovaPushV5.register().then(function (pushToken) {
            console.log('[+] Token: ' + pushToken)
        }, function (err) {
            console.log('[!] Push error: ' + err)
        });
    });

  });
})

When deploying the app to my iOS device using Xcode I obtain the expected result. Where ever I put the event listeners for the notifications (code below) I cant seem register an incoming notification. I used http://www.pushwatch.com/apns/ to test send the push notifications

$rootScope.$on('$cordovaPushV5:notificationReceived', function(event, data) {
    console.log('[+] Notification received')
});

Could anyone describe the best practice as to where to place these event listeners and point me in the right direction to fix the issue? If anyone needs any further info just let me know!


#2

Im having the same issue but in android.