B4J Question Firebase: Send a batch of notifications

dieterp

Active Member
Licensed User
Longtime User
Is it possible to send a batch of notifications in one api call using Firebase? I have distinct messages that need to be sent to multiple individual devices at at one time, and rather than send each one off individually I'd like to send them off in a batch. The Firebase documentation does give an example of this, but it isn't quite clear to me on exactly how it must be handled
 

dieterp

Active Member
Licensed User
Longtime User
I'm using the topic as a unique identifier per user, so there won't be any users that are subscribed to a "general" topic that will send out the same notification to multiple users
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
If I have different topics though that I want to send out, and I want to send them all out in one api call, how would I group all of the topics/messages together?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I'm using the topic as a unique identifier per user, so there won't be any users that are subscribed to a "general" topic that will send out the same notification to multiple users
I think each user should subscribe to a "private" topic (unique user id) and more than one "public" topic (such as general, cats, dogs, etc)

Eg.
user id = 001
topic = 001, general, cats

user id = 002
topic = 002, general, dogs

user id = 003
topic = 003, general, dogs

If I have different topics though that I want to send out, and I want to send them all out in one api call, how would I group all of the topics/messages together?
I never tried to group topics but according to Firebase doc, it says that we can use condition.
Maybe in the sending tool, we can put the condition in the map.

B4X:
Dim message As Map = CreateMap("condition": "'dogs' in topics || 'cats' in topics", "notification": notification, "data": data)
You can include up to five topics in your conditional expression.

If things become more complicated or you have a lot of users, I think you need to figure out how to group your unique users on your server/sending tool with a database.
When the app starts, subscribe/unsubscribe topics in the background when it is necessary.
 
Upvote 0

dieterp

Active Member
Licensed User
Longtime User
OK thanks for the detailed feedback. Let me play around with this a bit and see what I can figure out
 
Upvote 0
Top