UILocalNotification custom sound is not playing in iOS7

青春壹個敷衍的年華 提交于 2019-11-28 09:06:39

Did you try to turn off "Do not disturb" mode off? I have the same problem, then I found out "Do not Disturb" is on. After turn off that, it all works the right way.

try using .caf file instead of .mp3

afconvert -f caff -d LEI16@44100 -c 1 wolf.wav wolf_out.caf
vijay

My guess is your sound isn't formatted appropriately to play by the OS. Make sure your sound is formatted in IMA4 format. Also, make sure your file is in your application bundle, and you should be good to go.

For more reference and similar question, see this SO question.

Choose custom sound for Local Notifications

Here is a link for Apple's Local and Push Notification Guide. It explains the sounds in detail and the default sounds that can be used.

I ran into the same issue, I had to do the following steps:

  1. Convert the file from mp3 or wav to caf. As stated in other answers you can convert wav, aif and mp3 files in terminal using the command:

    afconvert -f caff -d LEI16@44100 -c 1 in.mp3 out.caf

  2. You can also export with Quicktime 7 as .aif with the following settings Linear PCM Rate 44.100 Linear PCM sample size 16 these aif files seem to be supported.

  3. Make sure you files are less than 30 seconds, i.e 29 seconds or less.

  4. Add you files to the root of your bundle, you can drag drop into Xcode or right click "add files to (projectname)" Note you must select the following options: a)Destination Copy items if needed b)Add to targets (your build name(s)) 4)Reference the file by its name including the extension e.g notif.soundName = @"sound.caf";

Make sure you delete the app from the device / simulator between tests or you will not see the results of your changes.

If your still having problems, check the sound file file is in the root of the project. Check the Sound file "Target Membership" is selected in the show file inspector.

I didn't get any idea why it did work.

But, at last I have solved my problem by making a new project xcode 5.0 and ported old project to this new project and this did work. So It's working and I can get sound too.

Hopefully it can work for others too.

Please try first whether setting->notificationcenter->sounds is not off.Then check whether in setting->sounds->slider is not on zero.That means if u have sounds on zero that will not allow sound to come up. Hope that helps.

Check that the "Sound Effects" is not mute or low. The volume may be high but if the Sound Effects volume is mute then the local notification may not sound. U can increase it when you are in the Home screen of iOS and then press the volume up button.

If mp3 file is edited with some tool, it is possible that something was missed by edit tool.

I had similar problem while trying to play mp3 file as local notification sound. Sound was shorter than 30 seconds, it was bundled, everything appears regular on the surface. After few hours i have realised that problem was caused by online mp3 cutter tool. I have find better editor, and file became playable on notification.

Make sure the sound is added to the main bundle!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!