0
votes

I send a parse push notification which the app receives, but the sound requested does not play, instead the default sound plays. The sounds have been saved by the app in the documents folder. I can check in iTunes that they are there. At some point this was working, but for some reason it has stopped playing the requested sounds. If I log the push notification user info dictionary the sound name is correctly there:

2015-01-11 12:17:41.356 My App[239:60b] didReceiveRemoteNotification, userInfo: {
    aps =     {
        alert = "XXX says FOO from the console!";
        sound = "w8nmridutW_v1.mp3";
    };
}

Any ideas?

2

2 Answers

1
votes

It is possible that the audio format that you use is not supported. Was it a different file when it was working ? Check with the apple documentation.

0
votes

According to the documentation here, mp3 isn't a supported file type. Are you sure you were getting this mp3 file to play before? If so, you were experiencing undocumented/unsupported behavior.

Here's the pertinent bit:

Preparing Custom Alert Sounds

For remote notifications in iOS, you can specify a custom sound that iOS plays when it presents a local or remote notification for an app. The sound files must be in the main bundle of the client app.

Custom alert sounds are played by the iOS system-sound facility, so they must be in one of the following audio data formats:

Linear PCM
MA4 (IMA/ADPCM)
µLaw
aLaw

You can package the audio data in an aiff, wav, or caf file. Then, in Xcode, add the sound file to your project as a nonlocalized resource of the app bundle.

You may use the afconvert tool to convert sounds. For example, to convert the 16-bit linear PCM system sound Submarine.aiff to IMA4 audio in a CAF file, use the following command in the Terminal app:

afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v

You can inspect a sound to determine its data format by opening it in QuickTime Player and choosing Show Movie Inspector from the Movie menu.

Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.