Failed to send data message using firebase console

I use the firebase console and can only send Notification messages from it.

Is there a way to send data messages using the same?

+19
source share
5 answers

Now you can send a notification notification via the console. Note that it is different from data messages; notification messages only trigger the onMessageReceived when the application is in the foreground.

They are located on the advanced options tab on the compose message screen.

enter image description here

Just expand it and enter a key / value map.

enter image description here

They will be included in the notification data field.

+2
source

The Firebase notification console can only be used to send notifications. It cannot be used to send data messages.

See the table for message types in the Firebase documentation :

Notification message

Usage scenario: FCM automatically displays the message to end devices on behalf of the client application. Notification messages have a predefined set of user-visible keys.

How to send:

  • Use your application server and FCM API: set the notification key. May have additional data payload. Always collapsible.

  • Use the notification console: enter the message text, name, etc. and send. Add an extra data payload by providing custom data in the notification console. Always collapsible.

Data message

Usage scenario: the client application is responsible for processing data messages. Data messages only have custom key-value pairs.

How to send:

  • Use the application server and FCM API: set only the data key. It can be either collapsible or awkward.
+19
source

Look here: Firebase push notification update database , my post since June.

In conclusion, you need to send an HTTP POST request to https://fcm.googleapis.com/fcm/send

 https://fcm.googleapis.com/fcm/send Content-Type:application/json Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA { "data": { "score": "5x1", "time": "15:10" }, "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..." } 
+11
source

You can test both the notification and the data message using Postman (the remaining client to check the http request). See screenshots:

enter image description here

In the header of the pass:

 key:Content-Type, value:application/json key:Authorization:key=<Server key> 
+8
source

Hi, someone will find the option to send a data message from the Firebase console. Please suggest.

0
source

Source: https://habr.com/ru/post/1012539/


All Articles