4

When sending an APN to an iOS device using HTTP v1 API, the Apple documentation states that if apns-priority is set to 10, then

Notifications with this priority must trigger an alert, sound, or badge on the target device

The documentation at Firebase seems to suggest adding to apns JSON object:

I am only successful when setting the priority only with the following in the JSON POST:

"apns": {
            "headers": {
                "apns-priority": "10"
            }
        },

When I POST the following as documentation suggests:

...
"apns": {
            "headers": {
                "apns-priority": "10"
            },
            "payload": {
                "sound": "default"
            }
        },
...

a 400 - Bad Request returns back from FCM server. If I exclude the payload json section, the POST works.

Also tried the following:

...
"apns": {
            "headers": {
                "apns-priority": "10"
            },
            "sound": "default"
...

still get a 400 - Bad Request

How do I set sound on a the APN within the SDK API JSON POST? A default sound is sufficient.

Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120

2 Answers2

4

The sound object needs to be part of an aps object:

...
"apns": {
   "headers": {
       "apns-priority": "10"
    },
    "payload": {
        "aps": {
            "sound": "default"
        }
    }
 },
...
sanmai
  • 29,083
  • 12
  • 64
  • 76
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
1

Based on your JSON, it appears you are using the HTTP v1 API.

The "apns" specific dictionary is described here.

For example, in order to play the default sound:

...
"apns": {
  "headers": {
    "apns-priority":"10"
  },
  "payload": {
    "sound":"default"
  },
},
...
Eran
  • 387,369
  • 54
  • 702
  • 768