Tutorial for sending rich media push notification via firebase

892 views Asked by At

Notification service extension is not triggered when notification is sent via firebase. It will show regular notification without image.

What is the exact payload I have to send.

I already tried this payload:

{ to = fedAu7oCO78:APA91bFAdcwctoVVcj-KtfQwD5hdBN7shcgw9QRgh-xQoLlKgBptqG2fxSYmL9T73BY5yOi81OOFbUVoZJp8b4hwPTCxvK4ZvR6hek, content_available = True, mutable_content = True, notification = { icon = myicon, badge = 1, sound = default, body = testing, title = iostest, NotificationImage = https://NotificationImage/822cf50ae5944995a033c51bf1c857a3banner1.jpg}, data = { mediaUrl = https://www.manijewel.com/NotificationImage/822cf50ae5944995a033c51bf1c857a3banner1.jpg }, 
priority = high, time_to_live = 6000 }

or

{
   "to": "dWB537Nz1GA:APA91bHIjJ5....",
   "data":
   {
      "message": "Offer!",
      "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
   },
   "notification":
   {
      "body": "Enter your message",
      "sound": "default",
      "content-available": 1,
      "mutable-content": 1
   }
}

And I get this:

I am using FCM for my project. It's have rich push notification for a type. I tried to modify most of possible ways to get push from FCM. I got only ordinary push from FCM, not with image.

I am also checking with APNS same coding using push try. I got what expected design for push notification.

Here on ios side payload

{
  "aps": {
     "alert": "Enter your message",
     "badge": 1,
     "sound": "default",
     "content-available": 1,
     "mutable-content": 1
  },
  "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
}

I use the pusher blog And

[1]: https://mobisoftinfotech.com/resources/mguide/ios-10-rich-notifications-tutorial/ to link rich media notification.Please help me how to sort this and where am i doing wrong.

thanx in advance

1

There are 1 answers

6
Neha Gupta On

Payload format should be like below:-

{
       "to": "dWB537Nz1GA:APA91bHIjJ5....",
       "content_available": true,
       "mutable_content": true,
       "data":
       {
          "message": "Offer!",
          "mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
       },
       "notification":
       {
          "body": "Enter your message",
          "sound": "default"
       }
}