Limitations for Firebase Notification Topics - firebase

I want to use Firebase notification for my android application and what i want to know is that is there any limitation for number of topics ? or for the number of users that can subscribe a topic ?
For example can i have 10000 topics with 1 million users for each of them ?

There is no limitation on the number of topics or subscriptions. There was a limitation of 1 million subscriptions for the first year after topics was initially launched but that restriction was removed at this year's (2016) Google I/O. FCM now supports unlimited topics and subscribers per app. See the docs for confirmation.

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.
Check this
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

Related

Can Firebase Messaging topic works well with 100K subscriptions?

I am a newbie to FCM.
I have a plan to create an FCM topic that contains 100.000 subscriptions.
Then I send a notification to the topic.
My question is: will 100.000 notifications be sent out successfully?
My question is: will 100000 notifications be sent out successfully?
Yes, it will. According to the official documentation:
Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
So first of is free of charge.
And according to the official documentation regarding topic messaging, it is said that:
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.

Clarification required regarding max topics supported in Firebase Cloud Messaging per Flutter App

The below page from firebase mentions that an App instance can not be part of more than 2K FCM topics.
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
One app instance can be subscribed to no more than 2000 topics.
I have seen related questions and answers. But I still have some doubts.
Let's say, my Flutter-based App XYZ has 50K users. And in a hypothetical scenario, each user has subscribed to one unique topic i.e. 50K topics across users.
Will I be still able to use Firebase FCM for all the 50K topics?
Please help with the clarification.
The limit is not on the number of topics that can exists, but the number of topics that a single app instance can subscribe to. A single app instance can subscribe to at most 2,000 topics, but there's no such limit across app instances.
So if each of your 50K users has a single app instance, they could subscribe to 50,000 * 20,000 topics.

Flutter FCM Topic named like a document

I am new to firebase cloud messaging and i search the best way to send notifications to clients.
I want people to be able to subscribe to new entry in subcollection like this :
books/{bookID}/comments/{commentId}/reply/{replyId}}
Is that bad if i use that kind of syntax?
so i can push notification on that topic when new reply are created
void fcmSubscribe(String bookId,String commentId) {
firebaseMessaging.subscribeToTopic('book-${bookiD}_comment-${commentId}');
}
or i need to use Individual Device Notifications and create entries like this
books/{bookID}/comments/{commentId}/notifications/{tokenId}}
i want to avoid firestore Read and Write.
You can use whatever valid topic names that you want. Use whatever you like - it's your choice. There is nothing particularly "bad" about your choice of name, as long as it works for you. Things can only go badly for you if you exceed one of the documented limits for topic messaging:
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.
If you're thinking that FCM is tied in any way to Firestore, that's not the case. You are not obliged to make anything match between your Firesore documents and your FCM topics.

How many topics an app instance can subscribe in FCM?

As mentioned in FCM documents, unlimited topic can be created for one Firebase application. But as the Firebase Admin SDK document: explains an error:
messaging/too-many-topics:- A registration token has been subscribed to the maximum number of topics and cannot be subscribed to any more.
I was not able to find this threshold value of maximum number of topics. Can anybody explain, what is the limit? How many topics an app instance can subscribe to in FCM?
I found the answer by running a subscription script for an app instance. After subscribing to 1999 topics, for the next subscription it started giving error: messaging/too-many-topics.
So the threshold value is 1999.
As much as the selected answer is correct, I'll like to post an absolute answer here.
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.

Firebase notification count restriction by topic on REST API

From my google search, we can send notifications to all users only from FCM console. Currently there is no support for that in REST API.
But we can specify a topic in REST API and whoever subscribed to that topic will get the notification.
Is there any restriction on user count on a single topic. What if 10k users subscribed to the topic and REST API choose that topic to send the notification. Will FCM send notification to all 10k users?
I'm asking this because when i try to send notification from console by topic it shows "<1000 estimated users". See below screenshot.
There is no restriction on the number of users that can subscribe a topic.
In your screenshot the annotation < 1000 estimated users means that FCM estimated that less than 1000 users have subscribed the specific topic.
This annotation can help you understand how many people will receive the message if you proceed and send to that topic.

Resources