不要GCM注册ID的过期吗? [英] Do GCM registration id's expire?

查看:406
本文介绍了不要GCM注册ID的过期吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道C2DM注册过期,你应该定期刷新注册ID。这是与GCM的情况?通过看在Android GCM指南(如下图所示)以下的code,好像你只做一次,不需要刷新,但我不看到明确写入任何地方,所以我只是想检查。

 最后弦乐REGID = GCMRegistrar.getRegistrationId(本);
如果(regId.equals()){
  GCMRegistrar.register(这一点,SENDER_ID);
} 其他 {
  Log.v(TAG,已登记);
}
 

解决方案

编辑:这个答案是远远过时了,我不知道目前的行为是


我发现自己的答案。你不明确需要重新注册所有按一次就好,时间在文档的例子。

此外,不像GCM和C2DM 的的previous版本,谷歌本身的刷新注册本身现在:一旦你从初始登记的注册ID你是好去,除了作为一个案例:你仍然需要重新注册,当用户升级到新版本(这种情况下是在上面的链接的例子还处理):

  

当一个应用程序被更新时,它应该无效其现有   注册ID的,因为它不能保证与新的版本来工作。   因为没有所谓生命周期方法,当应用程序是   更新,实现此验证的最好方式是通过存储   当注册ID存储当前的应用程序版本。

I know that C2DM registrations expire, and you are supposed to periodically refresh the registration ID. Is this the case with GCM? by looking at the following code on the Android GCM guide (shown below), it seems like you only do it once and don't need to refresh, but I dont see that explicitly written anywhere, so I just wanted to check.

final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
  GCMRegistrar.register(this, SENDER_ID);
} else {
  Log.v(TAG, "Already registered");
}

解决方案

EDIT: THIS ANSWER IS WAY OUT OF DATE, I HAVE NO IDEA WHAT THE CURRENT BEHAVIOR IS


I found the answer myself. You don't explicitly need to re-register all the time, just once according to the example in the docs.

Also, unlike previous versions of GCM and C2DM, Google itself does not refresh the registration itself now: once you have the registration id from the initial registration you are good to go, except for one case: you do still need to re-register when the user upgrades to a new version (this case is also handled in the example in the link above):

When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version. Because there is no lifecycle method called when the application is updated, the best way to achieve this validation is by storing the current application version when a registration ID is stored.

这篇关于不要GCM注册ID的过期吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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