UILocalNotification custom sound is not playing in iOS7

前端 未结 9 1624
别那么骄傲
别那么骄傲 2020-12-09 10:00

I\'m using UILocalNotification in an application.

In the application there are two sounds which are played conditionally- I have applied proper conditio

9条回答
  •  鱼传尺愫
    2020-12-09 10:38

    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.

提交回复
热议问题