Ionic 2 and One Signal how to use the handleNotificationOpened () function

1

I have an application that is 90% ready, notifications are already configured with One Signal, however, I want to send the user to a specific page when he clicks the notification, and this page may be different depending on the notification I submit. Example: I send a notification about Account Balance, I'll send it to the balance page, if I send an upgrade notification, I'll send you an upgrade page. All the examples I've seen in the documentation are in Java. Here is the Onesignal code:

InitializeApp() {
this.platform.ready().then(() => {
  setTimeout(() => { this._SplashScreen.hide(); }, 3000);
  this._OneSignal.startInit("99bb8873-4807-44c6-871f-7c3711201e34", "153883364067");
  this._OneSignal.inFocusDisplaying(this._OneSignal.OSInFocusDisplayOption.Notification);
  this._OneSignal.setSubscription(true);
  this._OneSignal.handleNotificationReceived().subscribe(() => {
    // handle received here how you wish.
  });
  this._OneSignal.handleNotificationOpened().subscribe(() => {
    // handle opened here how you wish.
  });
  this._OneSignal.endInit();
});

}

I need to use handleNotificationOpened () to customize the user's landing page within my application.

    
asked by anonymous 05.07.2017 / 23:50

1 answer

0

In this way you receive the values sent by One Signal and can deal with the received data.

this._OneSignal.handleNotificationOpened().subscribe((data) => {
   console.log(data);
});
    
07.07.2017 / 18:42