Reputation: 7556
I'm able to see the notification in system tray when the app is in Background.
But, I would like the notification to be visible in system tray even if the app is in Foreground.
I tried the following on Android:
https://fcm.googleapis.com/fcm/send
as described here with both data
and notification
paylods: Again, I can only see the notification in system tray when the app is in background.This document mentions:
Messages with both notification and data payload, both background and foreground. In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.
What am I missing?
I'm using Android and Cordova/Ionic.
Upvotes: 7
Views: 5655
Reputation: 811
It is Unity issue but I think the FCM core is the same.
Showing FCM push notification in tray when app is in foreground
The answer is
You have to redirect this to a local notification manually
Upvotes: 0
Reputation: 450
At foreground you can use Local Notification :
https://ionicframework.com/docs/native/local-notifications/
Upvotes: 0
Reputation: 317828
If you want a notification to appear when the app is in the foreground, you will have to send a message with a data payload, then write code to handle that in your app, as described by the documentation you referenced.
When you send a message with a notification payload, FCM works exactly as you described. When then app is in the background, it will display a notification for you. When in the foreground, it will not.
Please note that data and notification payloads behave differently, as described in the documentation.
Upvotes: 2