gpt4 book ai didi

android - FirebaseInstanceIdService onTokenRefresh() 是否仅在应用程序运行时调用?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:26:43 26 4
gpt4 key购买 nike

正如标题所暗示的那样,如果我为 FCM 通知注册了一个 Android 应用程序并且该应用程序在后台运行或有一段时间没有启动并且 token 发生变化,onTokenRefresh()调用?

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

谢谢

最佳答案

触发onTokenRefresh() 时的事件已包含在FirebaseInstanceIdService documentation 中:

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.

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

  • App deletes Instance ID
  • App is restored on a new device
  • User uninstalls/reinstall the app
  • User clears app data

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

另外,FirebaseInstanceIdService 类扩展了 Service类,无论应用程序是在前台还是后台,它都可以运行。

关于android - FirebaseInstanceIdService onTokenRefresh() 是否仅在应用程序运行时调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41582052/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com