GCM错误= MissingRegistration通过JSON发送消息 [英] GCM Error=MissingRegistration sending messages via JSON
本文介绍了GCM错误= MissingRegistration通过JSON发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我测试推GCM
标题:
的User-Agent:提琴手
授权:键= AIzaSyAkXfcuLLCZ-5n18wwO6XeJ13g-z9ja
主持人:android.googleapis.com
内容长度:286
正文:
<$p$p><$c$c>{"registration_ids":["APA91bHyn8YHcH_vSuOo7_A0PMgF5SU1K0FebOFGKXYTqpN5x4eD0tVBvzQLn749TVcczN5gSjB1wqf5AzYfxFI_qskA1Nzipf-9MfdEom1PI1vkFqKIg9B8vZvPLOLozE7jaRzELuyDzpFRbO3Xh5lT-KDA"],"collapse_key":"8b990f5a-78fc-4bad-b242-ffc740a750fb","data":{"message":"message到设备}}
我有一个错误
错误= MissingRegistration
我的问题吗? 所有ID是正确的。
解决方案
您应该指定内容类型的标题是JSON。
内容类型:应用程序/ JSON
如果省略内容类型,则格式被假定为纯文本。
和纯文本的注册ID是通过在一个名为参数 registration_id
而不是 registration_ids
,这也解释了你 MissingRegistration
错误。
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.
解决方案
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.
这篇关于GCM错误= MissingRegistration通过JSON发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文