Saturday, 26 May 2018

How to create Payload for Rich Text Notification using FCM

I am implementing Rich Text Notification in one of my app. I know that I need the payload in the following format:

{
  "aps": {
      "alert": {
          "title": "", 
          "body": “”
      },
      "badge": 1,
      "sound": "default",
      "mutable-content": true,
      "content-available": true,
      "category": "defaultCategory"
  },
  "image_url": ""
}

Although when I tried with default APNS process I did it successfully, but I just faced a issue while implementing it using FCM, and problem is that I am not receiving the keys:

mutable-content: 1
category: defaultCategory

I explored about it and found a url FCM rich push notification payload for iOS , I tried with the mentioned keys as well.

"mutable_content": true,
"click_action": defaultCategory,

But even using these I am not getting correct result. Current payload I am receiving after final changes are:

{
    gcm.notification.category: defaultCategory, 
    image: /r/u/rustyredsmall.jpg, 
    type_id: XMH677878912-L-Blue, 
    type: Product, 
    aps: {
        alert =     {
           body = "new product notification message2018-05-24 00:00:00";
           title = "Product Notification";
        };
       badge = 1;
       sound = default;
    }, 
    0: {"mutable_content":true}, 
    gcm.message_id: 0:1527142412430945%98b85c5198b85c51
}

Any suggestion, how I can get the correct payload?



from How to create Payload for Rich Text Notification using FCM

No comments:

Post a Comment