Kishore Relangi
Kishore Relangi

Reputation: 2024

FCM: How to avoid duplicate notifications if a user has subscribed to multiple topics

Say User A has subscribed to Topics T1, T2 and T3.

If I send same notification to Topics T1 and T3. Will A receives two notifications ?

If So, how to avoid this duplicate notifications ?

Thanks

Upvotes: 5

Views: 2232

Answers (1)

L. Perez
L. Perez

Reputation: 139

You have to send your notifications to multiple topics at once as shown in firebase documentation:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
  "condition": "'dogs' in topics || 'cats' in topics",
  "data": {
    "message": "This is a Firebase Cloud Messaging Topic Message!",
  }
}

More details here: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging

Upvotes: 3

Related Questions