IOS - Add Customizable Alarm Sound
I would like to add a custom beep to my iOS app. I tried to add it to my Xcode project but doesn't seem to work. I am getting the default alert sound instead of my custom beep.
Forgive my ignorance, I know very little about audio file formats. I am confused if I am using the correct format.
Apple's documentation states that I need to use one of 4 formats (Linear PCM, MA4 (IMA / ADPCM), ΞΌLaw, aLaw).
What I've done
- I have a file with a .m4a extension (fast time)
-
I also tried using afconvert tool to convert it
afconvert test.m4a test.caf -d ima4 -f caff -v
-
The length of the sound file is well below 30 seconds.
- I added the file to my Xcode project by copying it and saving it where there are other source files.
When a notification is sent, I get the default alert sound, not my custom alert sound.
I tried the below 2 lines of code and it doesn't seem to work, instead I get the default sound
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.soundName = @"test.caf";
//or .m4a file
localNotif.soundName = @"test.m4a";
Questions:
- Is the .m4a format of the supported file supported (is MA4 and .m4a the same?)
- How to create an audio file in one of the supported formats. Does the Garage group have an option where can I save it in one of the supported formats?
- What am I missing?
source to share