I am trying to read Firebase notifications. It works fine, but I am stuck in receiving messages from the notification console when the application is not turned on.
I know the documentation says that:
If your application is in the foreground or in the background, you can receive a message in the onMessageReceived method, otherwise the user will receive a notification in the tray ... clicking on it will open the main action with the data inside the intent
But is there a way to catch every message from the notification console, even if the application is closed?
==== ANSWER ====
Find the answer here
Unable to send data message from notification console.
But there are other ways to send notifications to devices, and they will be found inside onMessageReceived!
You can use a terminal (Mac or Linux) or some service, such as Postman, to send a request for sending via this link: https://fcm.googleapis.com/fcm/send
with the following body:
{ "to": "/topics/your_topic_here", "data": { "text":"text", "text1":"text1", ... } }
You also need to add 2 headers:
- Authorization - key = your_server_key_here
- Content-Type - application / json
To get the server key, you can find it in the firebase console: Your project → settings → Project settings → Cloud messaging → Server key


source share