when does an android gcm token expire

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?



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.

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?


 ? FCM Token Issue in some android device
 ? FCM - onTokenRefresh() is never called
 ? Does firebase manage user data like device token, bundle id etc at their own when sending push notifications or we have to manage these data?
 ? Firebase FCM token - When to send to server?
 ? FCM - onTokenRefresh() is never called
 ? onTokenRefresh not getting called in signed APK, if previous version of app installed doesn't have FCM implemented
 ? FCM onTokenRefresh() sometimes not called
 ? FCM onTokenRefresh() Can't create handler inside thread that has not called Looper.prepare()
 ? Firebase FCM notifications click_action payload
 ? Firebase FCM notifications click_action payload