Reputation: 2940
Using the FCM plugin here I am getting the notifications using firebase.
let ready=await this.platform.ready();
this.fcm.onNotification().subscribe((data)=>{
alertdata);
},(error)=>{console.log(`error ${error}`);
});
The notifications arrive when the app is not running and are also handled properly when the app is running.
But tapping the notification when the app is closed just opens the app.
I want to know how can I code the functionality that when the notification is tapped custom action is taken bases on the payload received.
Upvotes: 1
Views: 555
Reputation: 544
You can use data.wasTapped to set the functionality
this.fcm.onNotification().subscribe(data => {
if(data.wasTapped){
console.log("Received in background");
} else {
console.log("Received in foreground");
};
});
code written in if condition will work when tapping on notification and code written in else condition will work when app is in foreground. you can also move to specific page by giving functionality in the conditions
Upvotes: 2