kierandes
kierandes

Reputation: 181

Firebase Cloud Messaging - having multiple topics - without message duplication

I've been going through documentation for Firebase Cloud Messaging (FCM), and I was wondering if anyone has this same issue.

I have a feed, where users can sometimes have multiple overlapping topics that the can be subscribed to. e.g. #News,#Weather could be in a post about a weather event.

The example given checks for either News or Weather ('News' in topics || 'Weather' in topics) in topics

My question is, will FCM just pick the first option it comes across eg. News and message people with the "news" tag, or will it also send the same message twice - creating a duplicate? (1 for news to a user, then 1 for weather).

Thanks in advance! Kieran

Upvotes: 2

Views: 778

Answers (1)

AL.
AL.

Reputation: 37778

A simple test should be able to figure this out. The corresponding users would only receive one message. The FCM server processes the request depending on the condition, in this case, you were using an OR condition -- meaning, as soon as one of the conditions becomes true (in your scenario, the first condition is if the token is subscribed to News), then the server would send the notification as per usual and would ignore the other conditions.

PS: I tested this out before posting, so I'm positive of the behavior.

Upvotes: 2

Related Questions