如何分析GCM响应来自服务器,PHP删除无效的注册ID [英] How to parse GCM respond to remove invalid registration id from server with php

查看:143
本文介绍了如何分析GCM响应来自服务器,PHP删除无效的注册ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于谷歌云消息...

I got a question about Google Cloud Messaging...

我送GCM到谷歌3注册的ID,那么谷歌回答说2注册的ID发送成功,一个没有,因为注册ID错了!

I send GCM to Google for 3 Registration IDs, then Google replies that 2 of the Registration IDs has been sent successfully and one not, because the Registration ID was wrong!

但它并没有告诉我哪注册ID尚未发送...

But it doesn't tell me which Registration ID has not been sent...

现在这里是我的问题: 我怎样才能解析谷歌GCM反应来获取它的注册ID尚未发送?难道谷歌有一个API或东西,这样我可以给它multicat_id,它告诉我它的注册ID有问题吗?

Now here's my question: how can I parse the Google GCM response to get that which Registration ID has not been sent? Does Google has an API or something so that I can give it "multicat_id" and it tells me which Registration ID had a problem?

任何帮助将这么多的AP preciated,我只是很困惑:)

Any help would be so much appreciated, I'm just so confused :)

推荐答案

它基于的顺序:

假设你发这样的:

{ "collapse_key": "score_update",
  "time_to_live": 108,
  "delay_while_idle": true,
  "data": {
    "score": "4x8",
    "time": "15:16.2342"
  },
  "registration_ids":["4", "8", "15", "16", "23", "42"]
}

,并从谷歌这样的响应:

And get this response from Google :

{ "multicast_id": 216,
  "success": 3,
  "failure": 3,
  "canonical_ids": 1,
  "results": [
    { "message_id": "1:0408" },
    { "error": "Unavailable" },
    { "error": "InvalidRegistration" },
    { "message_id": "1:1516" },
    { "message_id": "1:2342", "registration_id": "32" },
    { "error": "NotRegistered"}
  ]
}

这意味着,你发送的第三个注册ID(15)无效,第6(42)未注册。双方应该从数据库中删除。

This means that the 3rd registration ID that you sent (15) is invalid and the 6th (42) is not registered. Both should be removed from your DB.

这篇关于如何分析GCM响应来自服务器,PHP删除无效的注册ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆