Reputation: 2148
As per the the docs,
To protect the client app and app server from potential malicious re-use of registration tokens, you should periodically initiate token refresh from the server. When GCM registration token refresh is initiated from server side, the client app must handle a tokenRefreshed message with the GCM registration client/server handshake.
Are the steps to initiate gcm registration token refresh documented somewhere?
I know about InstanceIDListenerService
and onTokenRefresh
. Those are for creating a new token and updating it to your app server. But how to do specifically the following bit?
periodically initiate token refresh from the server
Upvotes: 3
Views: 2900
Reputation: 20004
The best way to do this would be to schedule a job on the server that sends a notification with ACTION
REFRESH_TOKEN
every few months (GCM recommends 6 months). On the client apps, on your message callback, switch
on the ACTION
and handle the refresh token.
Old answer
Have you seen this page: https://developers.google.com/instance-id/guides/android-implementation#refresh_tokens
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.
Upvotes: 4