How to redirect to specific route in ionic4 on click of push notification?

#1

how to redirect to specific route in ionic4 on click of push notification? P.S. I am using https://ionicframework.com/docs/native/fcm.

#2

Hi, @mayurbaldha
Try this:

this.fcm.listenToNotifications().subscribe(data => {
        if (data.wasTapped) {
            this.router.navigateByUrl('/pageName');
        } else {
          //Notification was received in the foreground. Maybe the user needs to be notified.
        }
      });

For more info about navigation Click here

In my case, this works Fine.
Hope it helps.

#3

@addwebsolution : I assume this code is in app.component.ts & Ideally it should work this way only.

But have you tried using a sidemenu pattern of ionic 4?
There are functions which needs to be called if app is loading normal. e.g. login check functions & routings.

If app is loading normally,I can call conditions in app.component.ts and check the same. for login check functions & routings.
but
If my app is launching after click of notification,redirections first loads initial route, then after
this.router.navigateByUrl(’/pageName’); works.
It doesn’t go directly to page.