android - GCM 注册 ID 会过期吗?

标签 android android-notifications google-cloud-messaging

我知道 C2DM 注册会过期,您应该定期刷新注册 ID。 GCM是这种情况吗?通过查看Android GCM指南(如下所示)上的以下代码,您似乎只执行一次并且不需要刷新,但我没有看到任何地方明确写,所以我只是想检查一下。

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

最佳答案

编辑:这个答案已经过时了,我不知道当前的行为是什么


我自己找到了答案。您不需要一直重新注册,just once according to the example in the docs .

另外,与以前版本的 GCM 和 C2DM 不同,Google 本身不会现在自行刷新注册:一旦您从初始注册中获得了注册 ID,您就可以了去吧,除了有一种情况:当用户升级到新版本时,您仍然需要重新注册(这种情况也在上面链接中的示例中处理):

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.

关于android - GCM 注册 ID 会过期吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11590482/

相关文章:

Android Listview和图片解码

android - NotificationCompat setSound(声音,STREAM_ALARM)不工作

android - 获取 MyFirebaseInstanceIDService 的 Activity 实例

php - 使用 GCM 向多个 android 设备发送推送通知

android - 如何在推送通知(Gcm)android 中显示图像?

android - 需要身份验证。使用您的 Google 帐户登录

android - 如何从 layout.xml 中删除默认的 cardview 边框

java - Android Notification Listener 重复 hell

android - GCM 不适用于应用程序

android - OkHttp Mock Web Server 和 Retrofit Mock 的区别