As per the FCM documentation on Android Message Handling, push notifications will only be displayed if the App is backgrounded. It is not possible for a notification to appear in the System Tray while the App is foregrounded.
However! I have an app built with Capacitor. The app is currently on beta using the Internal Testing tool suite of the playstore. On it, when sending push notifications, I receive them through the onMessageReceived
callback AND the System Tray even when the app is foregrounded.
According to the documentation, that shouldn't be possible. So, I thought maybe (without being able to confirm):
onMessageReceived
get triggered)An example of the FCM message package I'm sending using the firebase-admin
SDK (latest version). This is a notification message with the optional data
payload provided:
{
data: { // data },
notification: { title: "My title", body: 'My body' },
android: { notification: { priority: 'max', visibility: 'public' } },
apns: { payload: { aps: [Object] } },
tokens: // token
}
Some observations:
firebase-admin
SDK (that was using the now-closed legacy APIs) to the latest version of the SDK. Before, I didn't have this kind of issues.android.notification.priority
and .visibility
props, but I get the same issue.I've deployed to production. So far, the issue does not happen anymore. My only guess is something to do with the Google App Store test suite. I will be closing this question due to lack of information.