仅在应用运行时才调用FirebaseInstanceIdService onTokenRefresh()吗? [英] Is FirebaseInstanceIdService onTokenRefresh() only called when the app is running?

查看:82
本文介绍了仅在应用运行时才调用FirebaseInstanceIdService onTokenRefresh()吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所暗示的,如果我有一个注册了FCM通知的Android应用并且该应用处于后台运行或一段时间未启动且令牌发生更改,何时调用onTokenRefresh()?

Pretty much as the title suggests, if I have an Android app registered for FCM notifications and the app is in background or hasn't been launched in a while and the token changes, when is onTokenRefresh() called?

它将唤醒应用程序以调用onTokenRefresh()还是在下次启动应用程序时将其调用?

Will it wake the app to call onTokenRefresh() or will it just be called the next time the app is launched?

谢谢

推荐答案

在系统确定需要刷新令牌时调用.应用程序应调用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.

并且也如指定的那样,FirebaseInstanceIdService类扩展了 Service 类,无论应用程序是在前台还是在后台,它都可以运行.

And as also specified, the FirebaseInstanceIdService class extends the Service class, which can run regardless if the app is in foreground or background.

这篇关于仅在应用运行时才调用FirebaseInstanceIdService onTokenRefresh()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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