FCM token 何时到期?是6个月吗?
最佳答案
但它不会过期。如果发生以下情况之一,它会自行更新。
根据https://firebase.google.com/docs/cloud-messaging/android/client :
- -应用删除Instance ID
- -应用在新设备上恢复
- -用户卸载/重新安装应用程序
- -用户清除应用数据。
Monitor token generation
The onTokenRefreshcallback fires whenever a new token is generated, so calling getToken in its context ensures that you are accessing a current, available registration token. Make sure you have added the service to your manifest, then call getToken in the context of onTokenRefresh, and log the value as shown:
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
sendRegistrationToServer(refreshedToken);
}
编辑
onTokenRefresh()现在已弃用。 onNewToken()应改为使用。
关于android - FCM token 何时到期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41982619/