Search code examples
iosaudiocustomizationuilocalnotification

Custom sound for Local Notifications not working


I know this question comes up a lot. I've read through a lot of questions on here about this topic. But I've followed instruction and it's still not working. Here's the input for the sound

Content.sound = UNNotificationSound(named: "Sound.caf")

and the Sound.caf file is located in the main bundle.

The format of the Sound.caf file is IMA 4:1, 2 channels, 44100 Hz. The sound is only 29 seconds long. I'm sure all the above is the right criteria for a custom sound in local notification. However, I still get the default sound instead of my custom sound.


Solution

  • Go to target > Build Phases > Copy Bundle Resource > Click + . add Sound.caf to copy Bundle Resource . hopefully it will works.

    enter image description here