FCM Notification Payload for iOS

I am using FCM for my project. It has rich push notification for type. I tried to change most of the possible ways to get push from FCM . I got a regular click from FCM , not with the image.

I also check with the same APNS code using push try . I got the expected design for push notification.

Here is 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 is 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 } } 

I also need a category more about payload in FCM

I am missing some settings in the fire-base console or is it because of the payload.

+10
ios push-notification firebase firebase-cloud-messaging apple-push-notifications
source share
3 answers

Invalid mutable-content and content-available in your FCM payload. It should be formatted as mutable_content and content_available . Both are logical and must also be outside the notification parameter. For example:

 { "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 FCM category analog, you should use click_action :

User action clicks on the notification.

Corresponds to the category in the APN payload.

+21
source share

It worked for me. It seems that the accepted answer contains some unnecessary information.

 { "to" : "devicekey OR /topics/sometopic", "mutable_content": true, "data": { "mymediavideo": "https://myserver.com/myvideo.mp4" }, "notification": { "title": "my title", "subtitle": "my subtitle", "body": "some body" } } 
+2
source share

Just for the help

If someone wants to use the REST POST API, here it is, use the Postman with the configuration below

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

Title:

 "Content-Type": "application/json", "Authorization": "key=<Server_key>" 

BODY:

 { "to": "<Device FCM token>", "notification": { "title": "Check this Mobile (title)", "body": "Rich Notification testing (body)", "mutable_content": true, "sound": "Tri-tone" }, "data": { "url": "<url of media image>", "dl": "<deeplink action on tap of notification>" } } 

It. Thanks!!!

0
source share

All Articles