Data messages vs Notification messages, (collapsible and non-collapsible confusion)

187

Very interesting question!

It looks like the docs are confusing and somewhat contradictory in some places.

I did some digging and the following highlights should clear some of your doubts:

What do we mean by collapsible messages?

Official definition from docs:

A collapsible message is a message that may be replaced by a new message if it has yet to be delivered to the device.

Let's expand the above definition with some details:

Collapsible messages concept is only applicable when your messages are queued and not yet delivered to the reciever. (The reason for messages being queued might be because the reciever might have not access to the internet, or their mobile is switched off, etc.) It means that in the case of messages being queued, if messages are collapsed, you might only recieve the latest message on the receiver end when they're back online.

Let's take an example: The reciever's internet connection is turned off, and we send three messages, A, B and C. Now, when the reciever turns on his internet, he'll only get one message, C, if the messages are collapsible.

However, it's important to note that if the reciever has already recieved a message, let's say - message A, then when you send B, it won't replace the message A that's already delivered to receiver.


Notification messages are always collapsible?

Not true entirely.

When we read this line from the documenation, we believe that notification messages are always collapsible.

Except for notification messages, all messages are non-collapsible by default.

But when I tried sending multiple notification messages through Notification Composer from Firebase console, (turned off the internet on reciever device before sending), I found that when coming back online, I'm recieving all messages that I sent. Which leads us to belive that notification messages are non-collapsible!

But that's the half of the story!

When you send a notification message through some other means, like using FCM Post API, you get only the latest message from the queue. Which means notification messages are collapsible!

Conclusion: Notification messages are non-collapsible when sent through Notification Composer, rest of the cases, they are collapsible. (Docs do not clearly state this anywhere)


Data messages are non-collapsible, which means they're important, right?

Obvious answer seems to be Yes! but that's not the correct answere here.

Important messages should be sent as non-collapsible messages. But, non-collapsible is not equal to important messages!

Reason?

There are 2 sides of this explaination,

  1. Collapsible/Non-collapsible messages segregation is defined only to decide whether only the latest message is important for the user or all the messages sent till now are important for the user.
  2. This doesn't mean that non-collapsible messages will be delivered on high-priority as important messages. You still need to consider the message priorities that are dependant on platform specific rules.

So, collapsible/non-collapsible conecept comes to picture if the messages can to be delivered to the reciver. Whether the messages can be delivered on time or not is completely a different domain of message priorities and OS restrictions, etc.

Share:
187
iDecode
Author by

iDecode

When developers want to hide something from you, they put it in docs.

Updated on December 31, 2022

Comments

  • iDecode
    iDecode over 1 year

    Data messages:

    Docs says:

    Non-collapsible: Every message is important to the client app and needs to be delivered. Except for notification messages, all messages are non-collapsible by default.

    that means Data messages are non-collapsible and are considered important. However, docs also say:

    Data only messages are considered low priority by devices when your application is in the background or terminated, and will be ignored.

    So, are they actually important or not and if they are, then how come they be ignored if the app is in the background, for instance.


    Notification messages:

    Docs says:

    Except for notification messages, all messages are non-collapsible by default.

    I'm sending two notification messages through the Firebase Notifications composer and being collapsible, old message should collapse (or replaced by the latest one) but I can see both of the notifications being displayed on both Android and iOS.

    So, how come Notification messages are considered "collapsible"?

  • iDecode
    iDecode almost 3 years
    Wonderful explanation. I think Firebase team needs to hire someone like you for their documentation. But tell me, how did you know about these concepts since docs were/are always confusing.
  • iDecode
    iDecode almost 3 years
    I'd also like to add that when I sent notifications one after the other through the Notification Composer while the device was offline, I only saw the last notification when the device came online (tested it both ways, using "Send test message" and "Send regular message".
  • Maulik Hirani
    Maulik Hirani almost 3 years
    @iDecode, I'm glad the answer helped you. Like I said, I did some digging myself reading different answers and docs, and came to understand this. For the case of sending notifications through composer, it's a bit strange that we see different behaviours sometimes. I tried couple of times myself again today, and I'm seeing both behaviours (collapsible & non-collapsible) sometimes. I have a screen record of notification messages being non-collapsible when sent from notification composer: drive.google.com/file/d/1LWxYnLKK1sKCY-KOzNQHmoNlzXcVP9E9/…