Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70641

Capacitor Push Notification: navigate to route when the app is not in background

$
0
0

Hello!

Ionic 6 + capacitor 3 app.

The push notifications are working well in my app, tough I have one “problem”:
in my code I have this section:

    PushNotifications.addListener(
      'pushNotificationActionPerformed',
      async (notification: ActionPerformed) => {
        const data = notification.notification.data;
        if (data.internalRoute) {
          this.routingService.navigateByUrl('/' + data.internalRoute);
        }
      }
    );

If the app is running, everything works as expected otherwise, the first time I get a push notification it just open the App and only after this (doesn’t matter if the app is now running in background or foreground) if I send a new push notification, it navigates to the chosen route. (basically, it goes to the route only if the app is “loaded”)

I think it doesn’t work because that fragment of code is being executed while the app is not completely “running”, so it does nothing.

There is any way to translate my code in something like

**Wait for the app to be completely "awake" and only then execute this:**
 
this.routingService.navigateByUrl('/' + data.internalRoute);
 

thank you!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70641

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>