How to use native push plugin


#1

Hi,

i’m trying to use nativ push (https://ionicframework.com/docs/native/push/)

I do this :

const options: PushOptions = {
      android: {},
      ios: {
        alert: 'true',
        badge: true,
        sound: 'false'
      },
      windows: {},
      browser: {
        pushServiceURL: 'http://push.api.phonegap.com/v1/push'
      }
    };
    const pushObject: PushObject = this.push.init(options);

    pushObject.on('registration').subscribe((registration: any) => {
      console.log('Device registered', registration)
      var oldRegId = localStorage.getItem('registrationId');
      if (oldRegId !== registration.registrationId) {
        // Save new registration ID
        localStorage.setItem('registrationId', registration.registrationId);
        // Post registrationId to your app server as the value has changed
      }
    });

    pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));

    pushObject.on('notification').subscribe((notification: any) => {
      console.log('notification event');
    });

i never see notification event in my console only :

[Log] We have permission to send push notifications (cordova.js, line 1731)
[Log] Device registered – {registrationId: "da82e56c064b763fea6010d3265a5b8199fca5dc8233f4d4acf5371f2d422484", registrationType: "APNS"} (cordova.js, line 1731)

What i’m doing wrong ?


#2
pushObject.on('notification').subscribe((notification: any) => {
      console.log('notification event');
    });

You are waiting for notification but do you ever send one?
If yes, where?


#3

i though on('notification') was to send notification.
on the repo the example is only :

push.on('notification', (data) => {
	// data.message,
	// data.title,
	// data.count,
	// data.sound,
	// data.image,
	// data.additionalData
});

data is what i get or what i send ?