Is there a way to subscribe a existing topic to new topic in Firebase Cloud Messaging, so that all the registered clients of old topic will be registered to new topic.
Example: If I have a FCM topic name A and I create a new FCM topic B. Can I add topic A to topic B?
No, only client apps can determine which topics they want to subscribe to in order to receive messages. You can't route messages going to a topic through another topic. What you would have to do instead is program the server side code that sends the message to send to multiple topics as needed.
Related
FCM sends an event via onNewToken() whenever an app is installed in a device. Do we have any similar methods available to capture the event for topic subscription or unsubscription, when a device is subscribed to a topic (or) unsubscribed from a topic?
Looking for a way to store the topic subscription details along with the deviceToken for every topic created for an app.
I could not see any such methods similar to onNewToken() for topic subscription events.
Since the token can be refreshed by the server outside of the application's control, the server notifies the client when the topic changes.
Since your application itself subscribes to a topic, you already know when it happens and can track that yourself. So there is no server-to-client notification for when a client subscribes to a topic.
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.
Is there a way to secure validate subscriptions to topics? For example, is it possible to limit topic Test to a specific user with ID XXXXX? Is this possible with Cloud Functions?
firebaser here
To be able to subscribe to a topic, you currently need to know two things: the FCM token/instance ID of the app instance, and the path/name of the topic to subscribe to.
Knowing these two allows one to subscribe to the topic from any client. There currently is no public API to limit who can subscribe to what topics. So if you need to guarantee that the message is only delivered to authorized app instances, you should not use topics and instead delivery to each FCM token/instance ID directly from your own (server-side) code.
This request comes along regularly though, so I recommend that you file a feature request to add your vote.
Looking to setup a aws SNS topic - I intend to subscribe a third party to this topic and I’m hoping that I can use its message filtering to ensure said third party only gets the messages they need.
Is that possible? Since I control the SNS topic I’m hoping I can also control who gets to see what but the docs are not super clear.
From Amazon SNS Message Filtering - Amazon Simple Notification Service:
By default, an Amazon SNS topic subscriber receives every message published to the topic. To receive a subset of the messages, a subscriber must assign a filter policy to the topic subscription.
A filter policy is a simple JSON object containing attributes that define which messages the subscriber receives. When you publish a message to a topic, Amazon SNS compares the message attributes to the attributes in the filter policy for each of the topic's subscriptions. If any of the attributes match, Amazon SNS sends the message to the subscriber. Otherwise, Amazon SNS skips the subscriber without sending the message. If a subscription doesn't have a filter policy, the subscription receives every message published to its topic.
I started working with Firebase in order to simplify the use of Push Notifications of my app. Searching around the Docs I found the possibility to send a notification to a group of devices through a topic which the devices are subscribed to.
My doubt comes out here. When I subscribe the devices (using firebaseToken) to the topic I want to use, does this topic creates implicitly if it's not created?
If it doesn't, when and how can I create a topic to use it later?
I'm using Firebase Cloud Store an Firebase Messaging.
You don't need to create a topic in order to use topic messaging. It just works the way you expect as long as the server and clients all agree on the name of the topic.
Firebase Cloud Messaging isn't related to Cloud Firestore in any way, other than that they are both Firebase products and are seen together in documentation and the console.