43

I'm testing push GCM via Fiddler

Headers:

User-Agent: Fiddler
Authorization: key=AIzaSyAkXfcuLLCZ-5n18wwO6XeJ13g-z9ja
Host: android.googleapis.com
Content-Length: 286

Body:

{"registration_ids":["APA91bHyn8YHcH_vSuOo7_A0PMgF5SU1K0FebOFGKXYTqpN5x4eD0tVBvzQLn749TVcczN5gSjB1wqf5AzYfxFI_qskA1Nzipf-9MfdEom1PI1vkFqKIg9B8vZvPLOLozE7jaRzELuyDzpFRbO3Xh5lT-KDA"],"collapse_key":"8b990f5a-78fc-4bad-b242-ffc740a750fb","data":{"message":"message to device"}}

I've got a error

Error=MissingRegistration

Where is my problem? All ids are correct.

Eran
  • 387,369
  • 54
  • 702
  • 768
takayoshi
  • 2,789
  • 5
  • 36
  • 56

4 Answers4

115

You probably forgot to specify the content type in the header to be JSON.

Content-Type: application/json

If Content-Type is omitted, the format is assumed to be plain text.

And for plain text the registration ID is passed in a parameter called registration_id instead of registration_ids, which explains your MissingRegistration error.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • In 2019 it still has sense! – CoolMind Oct 14 '19 at 15:53
  • 1
    @SatyajitBehera perhaps you have a different issue. I haven't worked with GCM for quite a few years, but this answer seems to still be helpful for some people (based on recent votes). – Eran Jul 25 '21 at 06:28
5

For the new cloud Message, when you want to send a dwonstream message from the server, you need to use "to" to declaim the target registration id.

like below :

https://gcm-http.googleapis.com/gcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{ "data": {
    "score": "5x1",
    "time": "15:10"
  },
  "to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx..."
}
Zephyr
  • 6,123
  • 34
  • 33
  • 5
    So you must have the "to:..." if you want to send a push ? what if i want to send the push to all the users from a client ? (admin client for example..) – XcodeNOOB Aug 07 '16 at 10:43
2

For Firebase, You can get info from https://firebase.google.com/docs/cloud-messaging/http-server-ref#error-codes

Check that the request contains a registration token (in the registration_id in a plain text message, or in the to or registration_ids field in JSON).

Hamedz
  • 726
  • 15
  • 27
0

Swift 5

In my case receiver token was missing and after put the fcm receiver token its work fine for me
Shakeel Ahmed
  • 5,361
  • 1
  • 43
  • 34