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

how to redirect to specific route in ionic4 on click of push notification? P.S. I am using

Hi, @mayurbaldha
Try this:

this.fcm.listenToNotifications().subscribe(data => {
        if (data.wasTapped) {
        } 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.

@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.
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.

Any updates in this issue?
Same problem here.

I’m facing same issue. Can you help with it?

I solved this issue with a messy workaround. I dont know if I should be recomending this, lol… But this is what I’ve done.

I have an “Api” provider that I use to call some specific endpoints and make API calls. Then, I altered this class adding a new attribute “navigateTo”, and I set that field on the “notification” event, like this:


      async (msg:any) => {
        let addData = msg.additionalData

            this.Api.navigateTo = addData.navigateTo

Then, after the login event on the app:


Pretty simple, but I just dont know if this is the best way to go. Use this solution at your own risk lol

1 Like

Thank you so much!! will give a try… thanks alot

No problem, let us know If It worked :slight_smile:

Hi, I tried but it’s not working for me… btw thanks for the help :slight_smile:

I finally managed to solve my issue by referring to the following