Missing FCM Token

I am trying to verify FCM using Postman, but I always get the following error, even where there is an FCM token. I got a token on the Cloud Messaging tab: Firebase Cloud Messaging token.

<HTML> <HEAD> <TITLE>The request was missing an Authentification Key (FCM Token). Please, refer to section &quot;Authentification&quot; of the FCM documentation, at https://firebase.google.com/docs/cloud-messaging/server.</TITLE> </HEAD> 

Here is what I am sending.

 POST /fcm/send HTTP/1.1 Host: fcm.googleapis.com Cache-Control: no-cache Postman-Token: 9109eb13-245f-0786-21a5-6207f5426b44 Content-Type:application/json Authorization:key=AAAAfnYrKvU:APA91bFwgeM3zuFId6UDzvIHk9qZ3lKHnX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx { "data": { "message": "This is a Firebase Cloud Messaging Topic Message!", } }: 
+9
source share
4 answers

After spending several hours, I found that in Postman you should put the following in the headers.

 Key: Content-Type Value: application/json Key: Authorization Value: key=AAAAfnYrKvU:APA91bFwgeM3zuFId6UDzvIHk9qZ3lKHnX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (Firebase Cloud Messaging token) 

Then click "Body" and select "Raw", here you will add json.

  { "data": { "title": "new messages", "score": "5x1", "time": "15:10" }, "to": "/topics/alldevices" } 

I also found that you cannot send all devices excluding "to": you will need to subscribe to the theme of your application. In my case, I signed up for alldevices.

Now I can send "to": "/ themes / alldevices" and all applications will receive a notification.

+17
source

working code for me like this -

POST: - https://fcm.googleapis.com/fcm/send

Title -

  Content-Type: application/json Authorization:key=AAAATIOk_eI:APA91bHR-NRuK-cVTc0fsdQ-N4SOAzocN7ngomFzcV7GkeCCHb6PmCFl_7MXTEPbdw-r0MTU9UmSbyxaSxxxxxxxxx..... 

Body -

  { "registration_ids": ["fBclzMXz1UQ:APA91bE268ddn8DNB95LcU2XyhjjOXE-8PJ1nZ8y0yf1-4UuUX0fFNuae9Acj5BLYZwJq72tnNUjcUax9ZvRxxxxxxxxxxxxxxxxx...."], "notification": { "title": "Hello", "body": "This is test message." } } 
+10
source

This is an example of a postman's POST request for sending notifications to devices using tokens.

 Type: POST Url: https://fcm.googleapis.com/fcm/send Headers key: Content-Type, value: application/json key: Authorization, value: key="This is the key in your FCM project console->Settings->Cloud Messaging->Server Key"" body: "mode": "raw" { "to": "Token/s received to mobile end", "notification" : { "body" : "message", "content_available" : true, "priority" : "high", "title" : "title of the notification" } } 
0
source

working code ...

 make sure You subscribe to topic ="/topics/alldevices" in your android/iOS code. 

POST: - https://fcm.googleapis.com/fcm/send

Header-

 Content-Type: application/json Authorization:key=AAAAPfs2N44:APA91bFcDkUfTjbFQvrttpedPcZINcjNkofU_x35xxxxxxxxx..... 

Body-

 "notification":{ "title":"TITLE", "body":"BODY", "sound":"default", "click_action":"FCM_PLUGIN_ACTIVITY", "icon":"fcm_push_icon" }, "data":{ "landing_page":"second", "price":"$3,000.00" }, "to":"/topics/alldevices", "priority":"high", "restricted_package_name":"" } 
0
source

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


All Articles