FCM token missing

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":""
}

working code for me like this-

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

Header-

 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."
    }
}

After spending some hours I found that in Postman you have to 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 add the json.

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

I also found that you cannot send to all devices by eliminating the "to": You will have to have your app subscribe to a topic. In my case I made my app subscribed to "alldevices".

Now I can send "to":"/topics/alldevices" and all apps will receive the notification.


This is a sample postman POST request to send notifications to devices by 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"
     }
    }