Push notifications with Ionic2

Thanks again for the help, I finally managed to get it (almost) working :sweat_smile: When I get it done I’ll write here the step-by-step.

The current problem: ionic.io.bundle is being successfully included and bootstrapped, but when I tried the sample code you gave before (plus the code to get the device id):

this.zone = new NgZone({enableLongStackTrace: false});

Ionic.io();

this.push = new Ionic.Push({
  debug: true,
  onNotification: (data) => {
    this.popup.alert({title: 'You have a notification'});
    this.zone.run(() => {
     // do something here
    });
  }
});

this.push.register(function(token) {
    console.log("Device token:",token.token);
});

Surprise: the push.register callback was not being executed. I then traced back why and found out that the Push.init() was never being called from the constructor (push/push.js). This bit from the Push constructor was not being executed:

  IonicPlatform.getMain().onReady(function() {
    self.init(config);
  });

I can’t understand why, but if put the self.init(config) outside the IonicPlatform.getMain().inRead() it just works perfectly. Apparently IonicPlatform.getMain() never gets ready. Any ideas?

Thanks!