我想将推送通知发送到多个设备,我可以使用此帖子数据来完成:
{
"registration_ids" :
["id_1", "id_2", "id_3"],
"data" :{
"messageContent": "Good Morning People!"
}
}
但问题是,我怎么知道每个设备的结果,因为我得到的是整个帖子数据的结果。在这个例子中,我获得了成功3。
{
"multicast_id": 0000xxxx123123,
"success": 3,
"failure": 0,
"canonical_ids": 1,
"results": [
{
"message_id": "0:540728299xxxxxxxasdasdasdasdasdas"
},
{
"message_id": "0:540728299xxxxxxxasdasdasdasdasdas"
},
{
"message_id": "0:540728299xxxxxxxasdasdasdasdasdas"
}
]
}
如果我获得成功2且失败1,我怎么知道哪个设备未能发送?
答案 0 :(得分:0)
结果中的每个元素都应该是您发送给GCM的注册ID的顺序。
<强> 结果 强>
Array of objects representing the status of the messages processed. The objects are listed in the same order as the request (i.e., for each registration ID in the request, its result is listed in the same index in the response) and they can have these fields:
message_id: String representing the message when it was successfully processed.
registration_id: If set, means that GCM processed the message but it has another canonical registration ID for that device, so sender should replace the IDs on future requests (otherwise they might be rejected). This field is never set if there is an error in the request.
error: String describing an error that occurred while processing the message for that recipient. The possible values are the same as documented in the above table, plus "Unavailable" (meaning GCM servers were busy and could not process the message for that particular recipient, so it could be retried).