Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FCM rich push notification payload for iOS

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

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

Here my APNS 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"
}

Here FCM payload

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

Also I am need category more details about payload in FCM

Am I missing any setting in fire-base console or is that from payload.

like image 634
Mathi Arasan Avatar asked Mar 01 '17 12:03

Mathi Arasan


People also ask

Does FCM work in iOS?

FCM Background notifications works in Android; not in iOS.

What is rich push notification in iOS?

Rich push notifications are short pop-up messages sent to a user's device with a rich media attachment such as an animated GIF, video, or audio. They allow you to communicate with your customers in an inviting way even when they're not actively using your app or visiting your website.

How do I get push notifications on iOS?

Go to Settings and tap Notifications. Select an app under Notification Style. Under Alerts, choose the alert style that you want. If you turn on Allow Notifications, choose when you want the notifications delivered — immediately or in the scheduled notification summary.


1 Answers

The mutable-content and content-available in your FCM payload is incorrect. It should be formatted as mutable_content and content_available. Both are boolean and must also be outside the notification parameter. Like so:

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

For the counterpart of category in FCM, you should use click_action:

The action associated with a user click on the notification.

Corresponds to category in the APNs payload.

like image 176
AL. Avatar answered Sep 23 '22 04:09

AL.