我有一个pythongcm服务器(白名单)可以很好地接收来自android应用程序的消息,直到我在数据包中包含除字符串以外的任何内容,在这种情况下,我只在服务器上获取字符串值。你知道吗
例如,我的客户机发送了一条消息,其中包含一个名为data的包,该包中添加了一个字符串和一个int,如下所示:
data.putString("MSG_ID", ALARM_ID);
data.putInt("AA", 1);
我的服务器读取并打印如下:
if gcm:
gcm_json = gcm[0].getData()
msg = json.loads(gcm_json)
print msg
输出为:
{u'category': u'xxxAPPNAMExxxx', u'from': u'xxxxGCMID', u'data': {u'MSG_ID': u'alarm'}, u'message_id': u'1'}
再读几遍之后,我发现了我在前几次通读中一定错过的东西:
所以TLDR;只允许字符串。
相关问题 更多 >
编程相关推荐