FCM 令牌是否在应用更新时刷新?

Is FCM token refreshed on app update?(FCM 令牌是否在应用更新时刷新?)
本文介绍了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 中刷新令牌时,它都应调用 onTokenRefresh() 方法:

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 令牌是否在应用更新时刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)