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

Asked

Viewed 159 times

1

I have an app that is 90% ready, notifications are already set up with One Signal, but I want to send the user to a specific page when they click the notification, and this page may differ depending on the notification I send. Example: Send a notification about Account Balance, I send it to the balance page, if I send an upgrade notification, send it to an upgrade page. All the examples I saw in the documentation are in Java. Here’s 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 target page within my application.

1 answer

0


This way you receive the values sent by One Signal and can handle the received data.

this._OneSignal.handleNotificationOpened().subscribe((data) => {
   console.log(data);
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.