Can Firebase Messaging topic works well with 100K subscriptions? - firebase

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.

Related

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 to send a notification to a whole app in Firebase admin? [duplicate]

This question already has answers here:
Firebase Notification - send to user segment vs send to topic difference
(3 answers)
Closed 4 years ago.
The Firebase Admin documentation shows examples on how to send notifications to a specific user, or users subscribed to topics.
https://firebase.google.com/docs/cloud-messaging/admin/send-messages
In the Firebase Cloud Messaging Console though, it's possible to send a notification to all users of a specific app
That works regardless of the clients subscribing to topics.
How can I replicate that behaviour with the Firebase Admin libraries?
Based on my read of the documentation, it seems like you could automatically subscribe every new user to a topic such as "appWideAlerts" upon sign in. Then use this as your app wide notification system.
Send to a topic
Based on the publish/subscribe model, FCM topic messaging allows you
to send a message to multiple devices that have opted in to a
particular topic. You compose topic messages as needed, and FCM
handles routing and delivering the message reliably to the right
devices.
For example, users of a local weather forecasting app could opt in to
a "severe weather alerts" topic and receive notifications of storms
threatening specified areas. Users of a sports app could subscribe to
automatic updates in live game scores for their favorite teams.
Some things to keep in mind about topics:
Topic messaging supports unlimited topics and subscriptions for each app.
Topic messaging is best suited for content such as news, weather, or other publicly available information.
Topic messages are optimized for throughput rather than latency. For fast, secure delivery to single devices or small groups of
devices, target messages to registration tokens, not topics.
If you need to send messages to multiple devices per user, consider device group messaging for those use cases.

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.

Limitations for Firebase Notification Topics

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

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