应用程序更新时会刷新FCM令牌吗? [英] Is FCM token refreshed on app update?

查看:112
本文介绍了应用程序更新时会刷新FCM令牌吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android应用中使用FCM进行推送通知.我有下面的课程来获取fcm令牌.

I am using FCM in my android app for push notifications. I have the below class to get the fcm token.

public class MyFirebaseInstanceIdService extends FirebaseInstanceIdService {
    @Override
    public void onTokenRefresh() {
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
    }
}

在安装我的应用程序并且我能够获取令牌时,可以正确调用此名称.但是我不确定我的应用程序是否已更新(从Play商店),则此方法是否会被调用.该文档只是说,只要令牌更改,该方法就会被调用.但是更新应用程序可能不会更改令牌.

This is called correctly when my app is installed and I am able to get the token. However I am not sure if my app is updated(from play store) then this method will be called or not. The documentation just says that the method will be called whenever the token changes. But updating the app might not change the token.

推荐答案

@Dharmitabhatt在帖子中指出在评论部分,更新时,不会刷新注册令牌.

As pointed out in the post by @Dharmitabhatt in the comments section, a registration token is not refereshed when an app is updated.

每当在Android中刷新令牌时,都应调用

Whenever a token is refreshed in Android, it should call the onTokenRefresh() method:

在系统确定需要刷新令牌时调用.应用程序应调用getToken()并将令牌发送到所有应用程序服务器.

Called when the system determines that the tokens need to be refreshed. The application should call getToken() and send the tokens to all application servers.

这不会经常被调用,它是密钥旋转和处理由于以下原因导致的实例ID更改所必需的:

This will not be called very frequently, it is needed for key rotation and to handle Instance ID changes due to:

  • 应用删除实例ID
  • 应用已在新设备上还原
  • 用户卸载/重新安装应用程序
  • 用户清除应用数据

系统将限制所有设备上的刷新事件,以避免使用令牌更新使应用程序服务器超载.

The system will throttle the refresh event across all devices to avoid overloading application servers with token updates.

因此,您应该说更新应用程序不一定刷新令牌.

So you are right to say that updating the app doesn't necessarily refresh the token.

这篇关于应用程序更新时会刷新FCM令牌吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆