4

Trying to send an image to APNs using Firebase Cloud Messaging but the payload in Firebase Docs do not work.

Firebase Docs: https://firebase.google.com/docs/cloud-messaging/ios/send-image

## Request
curl -X "POST" "https://fcm.googleapis.com/fcm/send" \
     -H 'Content-Type: application/json' \
     -H 'Authorization: key={web_token}' \
     -d $'{
  "to": "fcm_token",
  "priority": "high",
  "apns": {
    "payload": {
      "aps": {
        "mutable-content": 1
      }
    },
    "fcm_options": {
      "image": "mage_urli"
    }
  },
  "data": {
    "Room": "PortugalVSDenmark",
    "Nick": "Mario"
  },
  "notification": {
    "title": "Portugal vs. Denmark",
    "body": "great match!"
  }
}'
Tal Zion
  • 6,308
  • 3
  • 50
  • 73
  • I also am trying to get this working and having trouble. First of all, I think headers needs to be on the same level as fcm_options and shouldn't be inside payload. https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsFcmOptions Secondly, did you do any of that extra stuff for enabling UserNotificationsUI / UNNotificationContentExtension ? https://stackoverflow.com/questions/37839171/how-to-display-image-in-ios-push-notification https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension – vesperknight Feb 02 '21 at 14:45

1 Answers1

2

So I ran into the same problem and I added image in the notification field in the payload which fixed it.

Here's an example:

"notification": {
  "title": "Portugal vs. Denmark",
  "body": "great match!",
  "image": "image-url"}

Seems like the documentation is pretty wrong.