Im currently testing to find the smallest fix to a problem we do have with firebase messages. I’m going to brainsdump here so you folks know where we are and where we are going.
Where we were
Kinds of Message.
GCM had two kinds of messages notification
messages and data
messages. Notification
messages are delivered to the notification tray when the app is inactive, data
messages are delivered to the app (even when in the background or closed).
notification
messages had this structure:
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
}
}
data
messages had this structure:
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
}
Fuse provided the following behaviour:
- if the app is in the background or closed we make a notification in the notification tray. We use data in the message to customize your notification (sound, title, body, etc)
- if the app is in the foreground we deliver the message striaght to JS with nothing in the tray
This gave us behaviour on Android that matched iOS APNs, which we felt was valuable for app similicity.
The bit that we had an example for but totally failed to explain in the tutorials was that in order for this mechanism to work the message HAD to be a data message
We also had the data laid out in a daft way:
...
body: JSON.stringify({
registration_ids: [regID],
data: {
notification: {
alert: {
title: 'Well would ya look at that!',
body: 'Hello from some other app',
icon: 'Foo.png'
}
},
payload: 'anything you like'
}
})
...
Where we are
The fact we do not handle notification
messages properly is a real bug and one I am working on this week.
However from testing I can report that the data
messages in the above format DO still work with Fuse.PushNotifications even if the app is in the background or is closed.
Where we are going
Naturally the notification
message bug needs to be fixed (and will be). I also want to move away from our suboptimal notification layout and use something more appropriate. This is a breaking API change though so our release guidelines require us to deprecate the old stuff for a period of time first.
The question of data
-v- notification
messages may remain. By using data
messages, we are able to do things that are not in the Firebase specification but that our customers have specifically asked for. One example of this is support for largeIcon in notifications, which is something Firebase do not yet support
Comments
Please shout below ! Note that we at Fuse won’t be able to take the ‘minimal viable product’ on this library as we have customers using specific features today, however we will get something that works great with how Firebase works, provides a sensible cross-plat behaviour and gives folks time to migrate.
I hope this clears up a little, I’m happy to expand on any part.