Restricting foreground notifications in ionic capacitor

Surya Dharmakrishnan - Nov 2 - - Dev Community

I am using AWS SNS to trigger firebase notifications for android like below.
The stack is ionic angular, capacitor
Versions - All latest

aws sns publish --endpoint-url https://sns.us-east-1.amazonaws.com --target-arn <arn here> --message '{"GCM":"{ \"notification\": { \"body\": \"Sample message for Android or iOS endpoints\", \"title\":\"TitleTest\" } }"}' --message-structure json

I am getting notifications at all scenarios. But the issue is i want to restrict in few areas. Let's say the user is chatting and i don't want to show the same chat notifications flooding.

I know that, with notification payload it gives background and data payload works only on foreground.

I need to know Usually how this scenario will be handled

Eventhough i dont listen to OnNotificationRecieved event, i am getting notifications.

If i am not using notification key and use data key, it is not triggered in background. But with this payload it triggers properly, but i am stuck in handling it

.