Parul Jain
Parul Jain

Reputation: 21

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.

Upvotes: 2

Views: 2285

Answers (2)

Magyar Miklós
Magyar Miklós

Reputation: 4272

The correct format is this (tested)

{
    "to": "deviceFCMtoken",

    "notification":{
        "title" : "Check this Title",
        "subtitle" : "Subtitle",
        "body" : "Body",
        "mutable_content" : true,
        "category" : "categoryID"
    },

    "data":{
        "image-url": "www.something.com"
    }

}

Upvotes: 2

nerowolfe
nerowolfe

Reputation: 4817

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"
 }
}

Upvotes: 1

Related Questions