0

I have implemented FCM in Xamarin Forms and is working as expected. But I want to removed all the notifications from the notification tray when a new push is received.

I have tried using the same collapse_key, but all the messages are received instead of the recent push.

Can someone help me with this?

KENdi
  • 7,576
  • 2
  • 16
  • 31
Ashish Kumar
  • 755
  • 2
  • 6
  • 25
  • Have you tried using [`tag`](https://firebase.google.com/docs/cloud-messaging/http-server-ref)? – AL. Jul 17 '17 at 09:45
  • @AL. yes , I tried giving "tag" in the key value pair in the custom option with the same string , but again got 2 messages instead of 1 – Ashish Kumar Jul 17 '17 at 09:51
  • The `tag` parameter should be in the `notification` payload, not in `data` (custom key-value pair) payload. Are you perhaps using the Firebase Notification Console to send the message? If yes, then you won't be able to set the `tag` parameter there. Try using [curl or Postman](https://stackoverflow.com/documentation/firebase-cloud-messaging/drafts/127316). – AL. Jul 17 '17 at 09:56
  • @AL. How can we achieve the same in iOS , any idea? – Ashish Kumar Jul 17 '17 at 12:00
  • It works differently for iOS. Haven't tried it myself, but you're going to have to use a `thread-id`. See my answer [here](https://stackoverflow.com/a/42433876/4625829) – AL. Jul 18 '17 at 09:57

1 Answers1

7

You should proceed with using the tag parameter, keeping in mind that it should be in the notification payload, not in the data (custom key-value pair) payload.

If you are using the Firebase Notification Console to send the message, then you won't be able to set the tag parameter there. Try using curl or Postman to send the message.

Graham
  • 7,431
  • 18
  • 59
  • 84
AL.
  • 36,815
  • 10
  • 142
  • 281