I am following this walkthrough for creating push notifications into a Xamarin forms app
https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-andro
try to put JSON key 'notification' in your request to firebase API but instead use 'data'
{
"to": "/topics/journal",
"notification": {
"title" : "title",
"text": "data!",
"icon": "ic_notification"
}
}
in this case,these messages trigger the onMessageReceived()
callback only when your app is in foreground
{
"to": "/topics/dev_journal",
"data": {
"text":"text",
"title":"",
"line1":"Journal",
"line2":"刊物"
}
}
in this case,theses messages trigger the onMessageReceived()
callback even if your app is in foreground/background/killed
but this is a topic that depends also on the device and that FCM has no total control over.
the more you could refer to https://stackoverflow.com/a/37845174/10768653
and https://stackoverflow.com/a/43131488/10768653