Firebase Cloud Messaging not sending aps payload in correct format for iOS Notification Content & Service Extensions

To start off, I'm going to mention that there are two types of message payloads for FCM. notification and data. See the documentation here

When 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:

{
    "notification": {
        "body" : "Eureka!",
        "title": "Patient is not doing well"
    },

    "data": {
        "category": "provider-body-panel",
        "mutable-content" : true,
        "click_action" : "provider-body-panel"
    }
}

What's wrong?

  • click_action should be inside notification.
  • mutable-content should be mutable_content (notice the underscore) and should be on the same level as notification.
  • (this one I might've misunderstood, but) There is no 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 and mutable_content when using the Firebase Notifications Console. You'll have to build the payload yourself, something like this:

{
    "to": "<REGISTRATION_TOKEN_HERE>",
    "mutable_content" : true,
    "notification": {
        "body" : "Eureka!",
        "title": "Patient is not doing well",
        "click_action" : "provider-body-panel"
    }
}

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:

{ 
  "to" : "YOUR firebase messaging registration id here",
  "mutable_content":true,
  "notification": {
    "title": "Its about time",
     "body": "To go online Amigo",
     "click_action": "NotificationCategoryIdentifier ForYourNotificationActions"
  },
  "data":{
    "customKey":"custom data you want to appear in the message payload"
    "media-attachment":"mycustom image url",
    "catalogID":"mycustom catalog for my custom app"
  }
}