Ionic 4 FCM onNotification not being called

Hi everyone,

I’ve been having trouble with this.FCM.onNotification not being triggered when receiving Push Notifications when the app is either closed, paused or in the foreground.

The notifications are received when the app is closed, but tapping on them simply takes me to the landing page of the app (I can’t read the wasTapped property to redirect the user because onNotification isn’t triggered).

I’m subscribing to onNotification in app.component.ts using the following code:

this.platform.ready().then(() => {

  this.fcm.onNotification().subscribe(data => {

    if (data.wasTapped) {

      this.router.navigate([environment.paths.notifications]);
          
      this.badge.clear();
          
    } else {

      this.setNotificationIndicator();

    }

  });

});

I’ve posted a question to SOF that has some more details, and I’ve posted to the ionic-worldwide slack channel, but nobody has been able to help me out.

Is anybody able to shed some light as to why this issue would occur?

Thanks

I’ve updated my original SOF post with what seems to be a passable solution for my needs, but I’d really like to know what the core issue is so I can replace the current (horrible) solution with something more reasonable.

If anyone has an explanation as to why I’m having the above issue, I’m eager to read about it.

Thanks.