How to open FCM notification to a specific page when app is not running


#1

Hi, I am working on notification and sending it via fcm notification test server ,
here is my code for that.

FCMPlugin.onNotification(
      (data) => {
        if(!data.wasTapped){
          console.log("tapped when killed"+JSON.stringify(data));
        }else if (this.platform.is('android')){
          this.nav.push(NotificationPage,{data});
          console.log("RecivedFromFCM :"+data);
        }
      
      },
      (e) => {
        console.log(e);
      }
    );

The issue is that it ONLY runs when you tap on the notification from the notification drawer while the app is in the background. So if the app is open and a notification arrives, the function doesn’t run. Basically, “Received in foreground” never fires, even when the app is in the foreground. I want “Received in foreground” to log as soon as a notification arrives, even before tapping it and also when the app is not running I am able to receive notification but on click, it goes directly to homePage but it should have to go notification page.

Any idea how I can accomplish this, please? Or am I missing something? :worried:


#2

try to use NavController insted of Nav in the push to go to NotificationPage

if you want to fire something when a notification arrive and the app is open you have to put the code inside “!data.wasTapped” , if you still want a notification to appear in the notification bar , you can use local notifications.


#3

thank you for your support