FCM notification tapped but not opening desired page

I am using Ionic FCM and Laravel FCm package to send notifications to the app.

The token gets stored in the Database, The notification is received in the app too. The problem is when the app is in background and notification is tapped the specific page isn’t opening.

The code for handling notification tapped is taken from the Ionic docs:

console.log('This will print in all cases');
this.fcm.onNotification().subscribe(data => {
  console.log('this will will print when app in background', data);

  if (data.wasTapped) {
    console.log('This never gets printed', data);
    console.log("Received in background");
    this.nav.setRoot(CommunicationPage, { 'message_id': data.page_id });
  } else {
    console.log('Data: this will will print when app in background', data);
    this.nav.push(CommunicationPage, { 'message_id': data.page_id });
    console.log("Received in foreground");

P.S: The notification is getting received including the payload (i.e page id to be opened) because when the app is on foreground I am able to push the screen to desired page.