3

Is the collapse_key needed for Android and iOS push notifications? If I specify collapse_key in payload, will FCM use it? Or it will add another collapse_key?

AL.
  • 36,815
  • 10
  • 142
  • 281
user3575232
  • 55
  • 2
  • 9

1 Answers1

4

Is the collapse_key needed for Android and iOS push notifications?

No, it is not needed, unless you do want to use it, then of course you would use it. This depends on whether you want the messages to be collapsible (meaning that the notification may be 'overwritten' in a sense, by another similar message with the same collapse_key value.

If I specify collapse_key in payload, will fcm use it?

Yes, assuming you don't go over the four-key limit. You choose whatever string value you want to be used as the key and FCM will use it. If, however, you have more than four keys, you will get un-expected behavior. You won't know which keys will work properly in that case.

Or will it add another collapse_key

No Sir.

Ryan
  • 1,988
  • 4
  • 21
  • 34
  • 1
    It's also good to know that if a Notification payload is used and no `collapse_key` is specified, an implicit `collapse_key` will be used. See this [post](http://stackoverflow.com/a/39682968/4625829). – AL. Oct 06 '16 at 06:55
  • Thanks for the clarifications. actually there was a collapse_key added in data section in my fcm payload, that's why fcm was not using this and was adding it's own. – user3575232 Oct 07 '16 at 14:40
  • Not a problem. If my answers helped to answer your three questions you could select it as the answer, otherwise it was still a pleasure to help! – Ryan Oct 07 '16 at 16:01
  • I am trying to use a collapse_key: "follow" like so but it is still showing notifications with the same collapse key independently and does not overwrite previous ones... any thoughts am I doing something counter-intuitive? Here is my question http://stackoverflow.com/questions/39923777/firebase-sending-multiple-push-notifications-instead-of-stacking-or-replacing – Lion789 Oct 07 '16 at 19:45