Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choose custom sound for local notifications

How do you change the sound that plays for local notifications? I use the code below to play the default sound:

notif.soundName = UILocalNotificationDefaultSoundName; 

So, I tried this below, and it didn't work. What should I do? Thanks for your help!

notif.soundName = @"sound.caf"; 
like image 217
Jack Humphries Avatar asked Aug 24 '11 04:08

Jack Humphries


People also ask

How do I add a custom notification sound to the notification folder?

To change your Samsung phone's notification sound, go to "Sounds and vibration" in the Settings app. You can import audio by downloading sounds to your phone and using the My Files app to copy them to the Notifications folder.


2 Answers

You can convert from wav and mp3 using:

afconvert -f caff -d LEI16@44100 -c 1 in.wav out.caf 
like image 200
Rafael Sanches Avatar answered Oct 11 '22 03:10

Rafael Sanches


That should work. Make sure the sound is actually in your app’s bundle, is in the correct format (linear PCM or IMA4—pretty much anywhere that explains how to convert sounds for iOS will tell you how to do that), and is under 30 seconds.

like image 35
Noah Witherspoon Avatar answered Oct 11 '22 02:10

Noah Witherspoon