GCM Regisration标识过期时间 [英] GCM Regisration Id expiration time

本文介绍了GCM Regisration标识过期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与有关GCM下一个问题挣扎。我阅读文档( GCM文件),看到了例如,通过谷歌如何实现Android应用内的GCM客户端,但在整个文档中有要注册ID到期没有提及。

I'm struggling with the next issue about GCM. I read the document (GCM document) and saw the example by Google how to implement the GCM client within Android app but in the entire document there is no reference to expiration of Registration Id.

我看了<一个href=\"http://stackoverflow.com/questions/16838654/handling-registration-id-changes-in-google-cloud-messaging-on-android/16839326\">that问题但比如有不符合由谷歌的GCM演示应用上次更新

I saw that question but the example there is not following the last update by Google to the GCM Demo App

我的问题是:


  1. 做了Regisration标识过过期吗?

  2. 如果一个Regisration标识过期,我怎么能知道(是有任何的事件)?

先谢谢了。

推荐答案

我将展开我的评论。

根据所有我在GCM文档和例子看,你应该只您的应用程序的新版本安装在设备上后,重新注册到GCM。您不必办理登记身份证过期。

Based on all I read in the GCM docs and examples, you should only re-register to GCM after a new version of your app is installed on a device. You don't have to handle expiration of the registration ID.

即使由于某种原因GCM决定给定设备上分配一个新的注册ID为您的应用程序,并没有您的应用程序和你的服务器都意识到这一点,下一次你的服务器推送通知到设备(使用旧的注册ID),它会得到新的注册ID为规范注册ID中,谷歌的反应,并能够相应地更新其数据库。我建议你​​将每台设备指派自己的唯一ID(由服务器分配),并从该设备接收ID时,它发送给您的注册ID。这样一来,如果注册ID是由服务器改变(从谷歌规范注册ID响应的结果),并在以后的某个点上的应用程序发送给您由于某种原因,旧的注册ID,你就会知道这两个ID的指以相同的设备

Even if for some reason GCM decide to assign a new Registration ID to your app on a given device, and neither your app nor your server are aware of it, the next time your server pushes a notification to the device (using the old Registration ID), it will get the new Registration ID as Canonical Registration ID in the response from Google, and will be able to update its DB accordingly. I suggest that you assign each device your own unique ID (assigned by your server), and receive that ID from the device whenever it sends you the Registration ID. This way, if the Registration ID is changed by the server (as a result of canonical registration ID response from Google), and at some later point the app sends you for some reason the old registration ID, you'll know that both IDs refer to the same device.

我能想到当它是有益的设置在你的应用的人工超时,并且当超时重新注册到GCM(并将其发送到您的服务器)的唯一情况,就是如果你的服务器是如此的非可靠它可能会失去其注册ID的DB(我见过这个人实际上发生在SO问题)。这将允许服务器逐渐恢复丢失的注册ID。

The only case I can think of when it's beneficial to set an artificial timeout in your app, and re-register to GCM when that timeout expires (and send it to your server), is if your server is so un-reliable that it might lose its DB of Registration IDs (I've seen questions on SO by people this actually happened to). This will allow the server to gradually recover the lost Registration ID.

这篇关于GCM Regisration标识过期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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