Ad

Firebase Cloud Messaging - How To Add Sound To APN

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.

Ad

Answer

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

...
"apns": {
   "headers": {
       "apns-priority": "10"
    },
    "payload": {
        "aps": {
            "sound": "default"
        }
    }
 },
...
Ad
source: stackoverflow.com
Ad