一个应用程序实例可以在 FCM 中订阅多少个主题?

How many topics an app instance can subscribe in FCM?

正如 FCM 文档中提到的,可以为一个 Firebase 应用程序创建无限的主题。但是正如 Firebase Admin SDK document: 解释了一个错误:

messaging/too-many-topics:- A registration token has been subscribed to the maximum number of topics and cannot be subscribed to any more.

我找不到这个最大主题数的阈值。任何人都可以解释一下,限制是什么? 一个应用程序实例可以在 FCM 中订阅多少个主题?

我通过 运行 应用程序实例的订阅脚本找到了答案。订阅 1999 主题后,下一次订阅开始出现错误:messaging/too-many-topics.

所以阈值为1999

尽管选择的答案是正确的,但我想 post 在这里给出一个绝对的答案。 Google Firebase Cloud Messaging

Some things to keep in mind about topics:

  • Topic messaging supports unlimited subscriptions for each topic. However, FCM enforces limits in these areas:

  • One app instance can be subscribed to no more than 2000 topics.

  • If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.

  • The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.