我的CCS服务器中有以下方法。
public static String createJsonMessage(JsonArray to, String messageId,
Map<String, String> payload, String collapseKey, Long timeToLive,
Boolean delayWhileIdle) {
Map<String, Object> message = new HashMap<String, Object>();
message.put("to", to);
if (collapseKey != null) {
message.put("collapse_key", collapseKey);
}
if (timeToLive != null) {
message.put("time_to_live", timeToLive);
}
if (delayWhileIdle != null && delayWhileIdle) {
message.put("delay_while_idle", true);
}
message.put("message_id", messageId);
message.put("data", payload);
return JSONValue.toJSONString(message);
}
现在,当我尝试使用此函数发送GCM消息时(尝试在一个请求中发送多条消息。所以我有一个像这样的JsonArray(gcm json消息):
<message id="lT2FX-2"><gcm xmlns="google:mobile:data">{"to":["APA91bGnOTbGWmIW6Bjq_derdLpLbdYo90eLdls7miIrBXSWPyKlWU7y_Dnp2y1AE41bdkQYo70egwi-QnRDzGPxeABvygLmiukLN5ZfcxfXq-D8ekDb1KaiJOsHHPH1bq5HOq9K4wWUDVYmWzAtMwfWUR5YEUUKDw","APA91bHTe_PMWa3xsqIlYebmNCeVaF7FbqtZ-QC4WxKltMnyDFIBakjr8TfWrL2cQr47XWxev4f13Mdjk-5LVTiFZ13hv1duGhib00skO2zmCoyAKQGETI7ECB6suMG9lFyAUW6_PfUiCS4eOvlshscdF6ztu80pkw","APA91bHj5cWhbnGmQ5h20Hx93JQeo5ejq3iJcY_fBNwxhPnSkvgRYRNbFzSzSgwXJDBDcb97CgvDfQukYAuFpCWj1-4d7CGWiD7sGkXyNheQuKhVbuTFKg32VdJNazrCT7-XX7GAOYxhEe-E9U-XoZmQ6N6FNua4wg"],"collapse_key":"newGreenStatus","data": ...
这不起作用,但当我切换回一个注册ID时(类似这样:
<message id="cXEMp-2"><gcm xmlns="google:mobile:data">{"to":"APA91bHj5cWhbnGmQ5h20Hx93JQeo5ejq3iJcY_fBNwxhPnSkvgRYRNbFzSzSgwXJDBDcb97CgvDfQukYAuFpCWj1-4d7CGWiD7sGkXyNheQuKhVbuTFKg32VdJNazrCT7-XX7GAOYxhEe-E9U-XoZmQ6N6FNua4wg","collapse_key":"newGreenStatus","data":
然后它再次运作。
我也尝试将“to”更改为“registration_ids”,但仍然没有变化。 (当然createJsonMessage
中的参数会更改回String。)
我在这里做错了什么?
答案 0 :(得分:1)