Ionic Push Notification event handlers. Which to use?

I am using Ionic push notifications for both Android and iOS.

On Android they work perfectly fine both when fired manually and also programatically via the API. On iOS it seems that they only come in manually via Ionic Cloud. So far I am not sure what is causing this however I noticed something that I am not sure about on the docs.

On the Ionic Docs for Push notifications there seem to be two different event handlers for when notifications come into the app. One being the one I am currently using:

$scope.$on('cloud:push:notification', function(event, data) {
  var msg = data.message;
  alert(msg.title + ': ' + msg.text);
});

and the other being

push.on('notification', function(data) {
    // do something with the push data
    // then call finish to let the OS know we are done
    push.finish(function() {
        console.log("processing of push data is finished");
    }, function() {
        console.log("something went wrong with push.finish for ID = " + data.additionalData.notId)
    }, data.additionalData.notId);
});

The former needs the $ionicPush injection while the latter is initialized as follows:

var push = PushNotification.init({
       "android": {
           "senderID": "XXXXXXXXXXX",
           "sound": "true",
           "vibrate": "true"
       },
       "ios": {
           "alert": "true",
           "badge": "true",
           "sound": "true"
        },
        "windows": {}
})

Can anyone please tell me which event handler I should use? I am thinking that this may have to do with me not receiving programmatic pushes on iOS

NOTE: Yes I have enabled push notifications and remote notifications on Xcode. Remember I am receiving manual pushes on iOS, just not the programmatic ones.

Thank you very much!

For some unknown reason, $ionicPush doesn’t expose the finish() method. And the documentation is wrong - they have copied it directly from the documentation for the underlying plugin


but the plugin is wrapped by the angular service for ionic.

The solution is to get access to the plugin which we can see (by looking at the source code)


is available at $ionicPush.plugin. Also, the wrapper converts the 'notification' event to 'cloud:push:notification'

so basically, this solution works for me

      $rootScope.$on('cloud:push:notification', function(event, data) {
        var msg = data.message;
        console.log("data = "+JSON.stringify(data));

        if (data.raw.additionalData["content-available"] == 1) {
          console.log("Found silent push notification, for platform "+ionic.Platform.platform());
         // handle the notification and then...
          $ionicPush.plugin.finish(function(result) {
                 console.log("Finish successful with result " + result);
               }, function(error) {
                 console.log("Finish unsuccessful with result "+error);
               });
        };
     });

I was also really surprised that the documentation is incorrect and would strongly recommend that it be fixed ASAP.
@max