Rich Push notification with firebase and sending push notification with FCM on ios devices

I have integrated the normal text based push notification through Firebase Cloud Messaging. The push is send through FCM server and its working fine.

But I am stuck on media based push notification including images and media based notification. I have also tested with postman console with format mentioned below:

Use a service api.

URL: https://fcm.googleapis.com/fcm/send

Method Type: POST

Headers:

Content-Type: application/json
Authorization: key=your api key
Body/Payload:

{ "notification": {
    "title": "Your Title",
    "text": "Your Text"
  },
    "data": {
      "message": "Offer!",
      "mediaUrl": "https://cdn.pixabay.com/photo/2018/01/21/01/46/architecture-3095716_960_720.jpg"
    },
  "to" : "to_id(firebase refreshedToken)"
}  

Through this, I am receiving only normal text based push. What should be the error or correct way to send rich notification in ios 10 or later device??

Thanks in advance.

1 answer

  • answered 2019-02-05 09:41 nerowolfe

    You should provide the mutable-content and content-available in your FCM payload. Both are boolean and must also be outside the notification parameter

    {
      "to" : "to_id(firebase refreshedToken),
      "mutable_content": true,
      "content-available": true,
      "data": {
        "message": "Offer!",
        "mediaUrl": "https://cdn.pixabay.com/photo/2018/01/21/01/46/architecture-3095716_960_720.jpg
      },
      "notification": {
      "title": "my title",
      "subtitle": "my subtitle",
      "body": "some body"
     }
    }