I have a strange issue. I have two way to send notifications in my Android app; one from the Android service and the other through FCM.
The scenarios are as follows:
Most likely your problem is the difference between notification-messages
and data-messages
.
Please read: https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages
Use notification messages when you want FCM to handle displaying a notification on your client app's behalf. Use data messages when you want to process the messages on your client app.
Currently the FCM Web Console only sends notification-messages
So all the messages sent via Web Console (or via API with a notification
payload) will be have in this way:
onMessageReceived()
.
If the behavior that you want is that onMessageReceived()
is always called:
then you need to use a data-only (no notification) message