根据 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.
启动 gcm 注册 token 刷新的步骤是否记录在某处?
我知道 InstanceIDListenerService
和 onTokenRefresh
。这些用于创建新 token 并将其更新到您的应用服务器。但具体如何做以下位呢?
periodically initiate token refresh from the server
最佳答案
执行此操作的最佳方法是在服务器上安排一个作业,每隔几个月(GCM 建议 6 个月)发送一次带有 ACTION
REFRESH_TOKEN
的通知。在客户端应用程序的消息回调中,切换
ACTION
并处理刷新 token 。
旧答案
你看过这个页面吗: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.
关于android - 如何启动 android GCM token 刷新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32167533/