4

I am curious about android Gcm Token Expire strategy. When I want me device registered with Gcm service to be able to receive Gcm push messages, I will register it with the API.

Then I will get a Gcm Token "A". If I never upgrade my app version code on play store. And will google refresh it with "B" and expire "A" automatically?

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". I am now wondering how can the client side know that the gcm Token "A" expired and got replaced with "B"

Can some one answer my question?

Thanks

Xiaogegexiao
  • 111
  • 1
  • 5

2 Answers2

2

Yes, implement onTokenRefresh() with doc

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. 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.

Dori
  • 18,283
  • 17
  • 74
  • 116
0

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

The Instance ID service initiates callbacks periodically (for example, every 6 months), requesting that your app refreshes its tokens. It may also initiate callbacks when:

  • There are security issues; for example, SSL or platform issues.
  • Device information is no longer valid; for example, backup and restore.
  • The Instance ID service is otherwise affected.

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?

Community
  • 1
  • 1
B. Roth
  • 359
  • 1
  • 3
  • 12