NoahL
NoahL

Reputation: 101

Firebase Cloud Messaging: send to devices subscribed to "TopicA" but not "TopicB"

I am using Firebase Cloud Messaging (FCM) for my Flutter app. Let's say I have three topics users can subscribe to: "TopicA", "TopicB", and "TopicC".

I know I can send a message to users who subscribe to TopicA and either TopicB or TopicC using the following code from the FCM documentation using this code: "'TopicA' in topics && ('TopicB' in topics || 'TopicC' in topics)"

But what if I want to send a message to someone who is subscribed to TopicA but not TopicB? The pseudocode for that would be something like: 'TopicA' in topics && 'TopicB' not in topics.

Is this possible with FCM? If not, what would the best solution be?

My current thought is creating an anti-topic for anyone not subscribed to TopicB ('NotTopicB') and auto-subscribing everyone to it. Then I could send messages to 'TopicA' in topics && 'NotTopicB' in topics, but this is clunkier and I'd rather avoid it if I can.

Upvotes: 0

Views: 11

Answers (0)

Related Questions