小智 39
它不会过期.如果发生下列情况之一,它会自动更新.
监控令牌生成
每当生成新令牌时都会触发onTokenRefreshcallback,因此在其上下文中调用getToken可确保您访问当前可用的注册令牌.确保已将服务添加到清单中,然后在onTokenRefresh的上下文中调用getToken,并记录该值,如下所示:
@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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19678 次 |
| 最近记录: |