(FCM) notification is only received when app is in background

Hi everyone I’m trying to for fcm push notification and successfully getting the push notification but only when my app is in the background, whenever the app is in the foreground the app doesn’t receive any push notification.
Can anyone please guide what can be done.

below is the code I use:

  this.fcm.getToken().then(token => {
      console.log(token);
      this.user.mcf = token;
    });
    
    this.fcm.onNotification().subscribe(data => {
      if(data.wasTapped){
        console.log("Received in background");
      } else {
        console.log("Received in foreground");
      };
    });