简体   繁体   English

什么时候android gcm令牌到期

[英]when does an android gcm token expire

I am curious about android Gcm Token Expire strategy. 我对android Gcm Token Expire策略感到好奇。 When I want me device registered with Gcm service to be able to receive Gcm push messages, I will register it with the API. 当我想要使用Gcm服务注册的设备能够接收Gcm推送消息时,我将使用API​​注册它。

Then I will get a Gcm Token "A". 然后我会得到一个Gcm令牌“A”。 If I never upgrade my app version code on play store. 如果我从未在Play商店中升级我的应用版本代码。 And will google refresh it with "B" and expire "A" automatically? 谷歌会用“B”刷新它并自动过期“A”吗?

If yes, when will it do it. 如果是,它何时会这样做。 I have viewed some articles saying that once "A" got refreshed with "B", then when the server try to send message to "A", server will get the new registration id "B". 我看过一些文章说一旦“A”用“B”刷新,那么当服务器尝试向“A”发送消息时,服务器将获得新的注册ID“B”。 I am now wondering how can the client side know that the gcm Token "A" expired and got replaced with "B" 我现在想知道客户端如何知道gcm令牌“A”已过期并被“B”取代

Can some one answer my question? 有人可以回答我的问题吗?

Thanks 谢谢

Yes, implement onTokenRefresh() with doc 是的,用doc实现onTokenRefresh()

Called when the system determines that the tokens need to be refreshed. 当系统确定需要刷新令牌时调用。 The application should call getToken() and send the tokens to all application servers. 应用程序应调用getToken()并将令牌发送到所有应用程序服务器。 This will not be called very frequently, it is needed for key rotation and to handle special cases. 这不会被频繁调用,需要进行键旋转和处理特殊情况。 The system will throttle the refresh event across all devices to avoid overloading application servers with token updates. 系统将限制所有设备上的刷新事件,以避免使用令牌更新使应用程序服务器过载。

Periodically, the token will expire, but the exact amount of time that it happens hasn't been released by Google. 令牌会定期到期,但谷歌尚未发布确切的时间。 There are, however, a few other instances in which a token might expire. 但是,还有一些令牌可能会过期的其他实例。

From the Android Implementation Guide on Instance ID 来自Android Implementation Guide on Instance IDAndroid Implementation Guide on Instance ID

The Instance ID service initiates callbacks periodically (for example, every 6 months), requesting that your app refreshes its tokens. Instance ID服务定期启动回调(例如,每6个月),请求您的应用刷新其令牌。 It may also initiate callbacks when: 它可能还会在以下情况下启动回调:

  • There are security issues; 存在安全问题; for example, SSL or platform issues. 例如,SSL或平台问题。
  • Device information is no longer valid; 设备信息不再有效; for example, backup and restore. 例如,备份和还原。
  • The Instance ID service is otherwise affected. 实例ID服务受到其他影响。

Also, I asked a large question (more like a series of questions in one) a while back about the same topic. 此外,我在一段时间内回答了同一主题时提出了一个大问题(更像是一系列问题)。 This might help you: When do GCM Tokens Expire and What is the InstanceID? 这可能会对您有所帮助: GCM令牌何时到期以及什么是InstanceID?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM