我在我的 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:
系统将限制所有设备的刷新事件,以避免应用服务器因令牌更新而过载.
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 令牌是否在应用更新时刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!