Determine which page to open when you click the Push Notification button in Ionic 2

My Ionic 2 App is already receiving push notifications. When you click on a notification (the application is closed), the application opens and displays the root page.

How to determine another page to display when the application opens after a notification has been clicked?

Ideally, I would pass in a push alert another field parameter called a "page", where I can determine which page to open.

Now all I do is to handle notifications inside my application:

this.push.rx.notification()
      .subscribe((msg) => {
        alert(msg.title + ': ' + msg.text);
      });
+4
source share
1 answer

I am using FCM native and this works for me,

this.push.rx.notification()
  .subscribe((msg) => {
  let messageData = JSON.parse(msg.messageData);
  let ref_this = this;
  if (msg.wasTapped) {
    switch (msg.notificationType) {
      case "push_chat":
        ref_this.nav.setRoot(ChatPage);
        break;
     case "push_Notify":
   ref_this.nav.setRoot(BookingAllPage);
        break;
      default:
        ref_this.nav.setRoot(Home);
        break;
    }
   });

Hope this helps you.

0

Source: https://habr.com/ru/post/1670468/


All Articles