abiieez
abiieez

Reputation: 3189

How to send firebase push notification with overlapping topic

The way I see it, this should be a common use case. For example I have 3 users who subscribe to following topic(s)

  1. User A > "CNN"
  2. User B > "Sports"
  3. User C > "CNN", "Sports"

The current problem is when I tried to send notification with message "Man Utd won 5-0" for both topics "CNN" and "Sports", the 3rd user (User C) will actually get 2 same notification.

What kind of logic should I put in the backend to ensure the 3rd user will get only 1 notification ?

Upvotes: 0

Views: 103

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598817

What you want can be done with an OR condition like this:

"('CNN' in topics || 'Sports' in topics)"

This message will be deliver to any user that is subscribed to CNN, to Sports, or to both.

For a more complete example and explanation see the Firebase documentation on sending messages to topics.

Upvotes: 1

Related Questions