Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCM Error=MissingRegistration sending messages via JSON

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.

like image 400
takayoshi Avatar asked Mar 18 '14 17:03

takayoshi


2 Answers

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.

like image 195
Eran Avatar answered Sep 20 '22 00:09

Eran


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..." } 
like image 21
Zephyr Avatar answered Sep 23 '22 00:09

Zephyr