I'm trying to achieve the following behaviour for push notifications using Firebase Cloud Messaging for Unity in an Android app:
If the app is in the foreground, handle it directly in the app (access key-value pairs in the push message). Do not show notifications in system tray, or possibly show notifications in the system tray, but then I must be able to clear it from the app.
If app is in the background, show notifications in the system tray. When the user clicks on a notification or clicks the app icon on the desktop, bring the app to the foreground, clear the system tray and access key-value pairs in the push message.
If the app is not running, show notification in the system tray. When the user clicks notification or starts the app from the icon, start the app, clear the system tray and access the key-value pairs in the push message.
Depending on whether I populate "data" and/or "notification" fields in the push message in the server, I am able to achieve the above options in different combinations, but I cannot figure out how to achieve all of them.
How do I go about achieving all three cases at once?