android - FCM token 何时到期?

标签 android firebase firebase-cloud-messaging

FCM token 何时到期?是6个月吗?

最佳答案

但它不会过期。如果发生以下情况之一,它会自行更新。

根据https://firebase.google.com/docs/cloud-messaging/android/client :

  1. -应用删除Instance ID
  2. -应用在新设备上恢复
  3. -用户卸载/重新安装应用程序
  4. -用户清除应用数据。

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/

相关文章:

firebase - 每次我从 Firebase Cloud Messaging 发送通知时,我的应用程序都会崩溃

android - 通过图库中的 "Share"按钮获取 Activity 中的图像 |安卓

android - react native : Android "Received status code 502 from server: Bad Gateway" from JCenter and Bintray being discontinued

ios - 如何将图像存储在 firebase 存储中并将它们的链接保存在数据库中?

java - Android 中的 Firebase 多个查询

javascript - Firebase 消息传递返回成功,但 webapp 未收到消息

android - View 翻转器 : OutOfMemoryError: bitmap size exceeds VM budget

java - PhoneAuthProvider.OnVerificationStateChangedCallbacks 没有被解雇

ios - 如何提取具体数据?

当应用程序处于前台时,Angular 8 firebase 推送通知不起作用