the onMessageReceived () method is not called
If the server sends a notification payload, onMessageReceived() not called when the application is in the background or killed.
To always call onMessageReceived() , the server must always send data and load useful data.
When you use the notification payload - Firebase will create a notification on its own, analyzing the notification payload, and the data will be transmitted using the intent of the targeted activity when you click on the notification.
Previously, in version com.google.firebase:firebase-messaging:10.2.1 was a handleIntent(Intent intent) method, but later they deleted it and forced firebase to process it completely.
I want to start my service using Push Notification while my application service is dead.
You can not. See the documentation for more details. You must schedule a job to complete the action in the background.
About the notification payload.
It might look like this:
{ "data":{ "id": 1, "key": value "key_1": value1 }, "to": "target --fhiT7evmZk8:APA91bFJq7Tkly4BtLRXdYvqHno2vHCRkzpJT8QZy0TlIGs......" }
source share