android – GCM测试,如何用canonical_id激发GCM服务器响应?

android – GCM测试,如何用canonical_id激发GCM服务器响应?,第1张

概述我已经成功实现了客户端/服务器 Android GCM应用程序.我的app服务器拥有device / registration_id对的数据库.消息通过Web可访问的PHP页面发送到设备.我试图在服务器端编写错误处理,特别是响应包含canonical_id的情况.开发人员文档非常清楚需要做什么以及为什么会产生这样的响应: Canonical IDs On the server side, as l 我已经成功实现了客户端/服务器 Android GCM应用程序.我的app服务器拥有device / registration_ID对的数据库.消息通过Web可访问的PHP页面发送到设备.我试图在服务器端编写错误处理,特别是响应包含canonical_ID的情况.开发人员文档非常清楚需要做什么以及为什么会产生这样的响应:

Canonical IDs

On the server sIDe,as long as the application is behaving well,
everything should work normally. However,if a BUG in the application
triggers multiple registrations for the same device,it can be hard to
reconcile state and you might end up with duplicate messages.

GCM provIDes a facility called “canonical registration IDs” to easily
recover from these situations. A canonical registration ID is defined
to be the ID of the last registration requested by your application.
This is the ID that the server should use when sending messages to the
device.

If later on you try to send a message using a different registration
ID,GCM will process the request as usual,but it will include the
canonical registration ID in the registration_ID fIEld of the
response. Make sure to replace the registration ID stored in your
server with this canonical ID,as eventually the ID you’re using will
stop working.

因此,在我的AndroID客户端应用程序中,我只有一个开发按钮,它将第二次向GCMRegistrar.register()注册设备,而无需首先注销它.我曾经假设这会让我的注册时间不同于我第一次注册它,并且从网上向设备发送消息(可能使用旧的ID)会给我一个带有canonical_ID的响应.

但是,第二次注册返回与第一次完全相同的reg_ID.

因此,通过我的服务器上的PHP发送消息将不会在响应中显示canonical_ID.我真的需要测试返回canonical_ID的情况,表明我需要更新我的数据库,因为我的PHP技能不是最好的!

因此,我将非常感激地提出关于如何激发这种回应的任何想法

更新:我刚试过从手机上卸载应用程序,然后重新安装它.我仍然得到相同的reg_ID.

解决方法 我回答了这个问题 – here. 您可以尝试按照我用于获取规范注册ID的步骤.它确实涉及卸载App,但也许你没有完成我在那里描述的所有步骤. 总结

以上是内存溢出为你收集整理的android – GCM测试,如何用canonical_id激发GCM服务器响应?全部内容,希望文章能够帮你解决android – GCM测试,如何用canonical_id激发GCM服务器响应?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1127276.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存