开发者

UILocalNotifications plays sound in Simulator but not on Device

开发者 https://www.devze.com 2023-03-07 17:07 出处:网络
I\'m just trying to include a UILocalNotification into my newest app. Everything works well, but the sound doesn\'t do what I want.

I'm just trying to include a UILocalNotification into my newest app. Everything works well, but the sound doesn't do what I want.

I included a ringtone called "Electro.caf" the开发者_运维问答 sound plays on my MacBook without problems. Even if I try it out in the iPhone Simulator as a Local Notification. But if I want to try it on my iPhone 4 (iOS 4.3.2) it doesn't work. It's not mute, volume is on maximum and I tried to delete the app, reinstall it and so on.

Is there anyone who figured out the same problem, or knows a solution?

Thanks mavrick3.


The iOS Simulator is case insensitive while the device is case sensitive. So make sure you write Electro.caf instead of electro.caf


This post by another user on Stack Overflow might help:

The bundle is on disk; it's just the ".app" directory. You should not write to files in this directory, however. While currently possible on Mac, it will break code signing. On iPhone, you already can't write into your own bundle, and we should expect to see this limitation in the future on Mac. You should write your application files into various directories under ~/Library or ~/Documents as appropriate.

Make sure than your sound length is less than 30 seconds and the sound file must be present into your main bundle


You are using wrong .caf file format.

To create a .caf file, use your iTunes.

iTunes -> preferences -> Import Settings -> import using : select AIFF encoder, make custom settings if you want click OK, again OK

then select music from your library and click: advanced -> create AIFF version drag & drop new generated file on desktop, and change extension from .aif to .caf

that's it, you have .caf file that will work on your iPhone device

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号