I'm trying to implement notifications using Firebase. The notification is received correctly when the app is in the background or foreground. So, the basic mechanics are working.
Now I've added Content Extensions and Service Extensions to the app. The Content Extension works when I use a local notification, but the Firebase message payload seems incorrect as far as the optional fields are considered. Here is a link to an image of my console:
And here is the Firebase remote notification payload that comes across (with some of the long Google numbers edited for anonymity:
{
aps =
{
alert =
{
body = "Eureka! 11";
title = "Patient is not doing well";
};
};
category = provider-body-panel;
gcm.message_id = 0:149073;
gcm.n.e = 1;
google.c.a.c_id = 2825604;
google.c.a.e = 1;
google.c.a.ts = 149073;
google.c.a.udt = 0;
mutable-content = 1;
}
It appears that the "category" and "mutable-content" are not in the correct place. They should be in the aps payload.
How can I get those options to be in the payload so that my app can correctly parse it and connect it with the Content and Service Extensions?
To start off, I'm going to mention that there are two types of message payloads for FCM.
notification
anddata
. See the documentation hereWhen sending notifications through the Firebase Notifications Console, it will be treated as a
notification
payload. However, if you add in Custom Data, it will add it in the payload as a custom key-value pair.For example, in your post, the FCM payload should look something like this:
What's wrong?
click_action
should be insidenotification
.mutable-content
should bemutable_content
(notice the underscore) and should be on the same level asnotification
.category
parameter for FCM,click_action
already corresponds to it.See the docs for the parameters here.
It it is currently not possible to set the value for
click_action
andmutable_content
when using the Firebase Notifications Console. You'll have to build the payload yourself, something like this:Then send it from your own App Server. You could also do this by using Postman or cURL
"mutable-content should be "mutable_content" (keyword for firebase server to send as mutable-content for IOS) as you mentioned in your post, I think you left out in edit.
Below is an example with also the corrected format for the data section in the json sent to the FCM server. So update would be: