I have been stuck on the same problem for a while, and I hope someone can help.
我一直坚持同样的问题,我希望有人可以提供帮助。
I created an alarm clock app, which uses UILocalNotification to play an alarm sound at the selected time.
我创建了一个闹钟应用程序,它使用UILocalNotification在所选时间播放闹钟声音。
My app was working fine on the simulator, but when I started testing it on an iPhone, the notification sound stopped ringing.
我的应用程序在模拟器上工作正常,但当我开始在iPhone上测试时,通知声音停止响铃。
I have the sound in .caf, about 20 seconds long, correct capitalization and everything, so I really can't figure out why it doesn't ring. I use the same sound file elsewhere in the app, and it works fine, so I do know the file is loaded properly. The notification shows up properly, just without the sound. And yes, I made sure the volume is turned up on my iPhone.
我有.caf的声音,大约20秒长,正确的大写和一切,所以我真的无法弄清楚为什么它不响。我在应用程序的其他地方使用相同的声音文件,它工作正常,所以我知道文件已正确加载。通知显示正常,没有声音。是的,我确保在iPhone上显示音量。
Does anyone have any idea why this is happening? Below is my code.
有谁知道为什么会这样?以下是我的代码。
Thank you in advance! -Ema
先谢谢你! -Ema
UILocalNotification* alarm = [[ULocalNotification alloc] init];
alarm.fireDate = pickedDate;
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.hasAction = YES;
alarm.alertAction = @"SNOOZE";
alarm.repeatInterval = 0;
alarm.soundName = @"Alarm11.caf";
alarm.alertBody = @"Alarm";
[app scheduleLocalNotification:alarm];
2 个解决方案
#1
0
I had the same problem and found a solution in a similar question on * (but I can't find it again to provide the link) - The solution to my problem was to open the System Preferences for my mac and open the Sounds option. In the Sounds screen, uncheck and then re-check the 'Play user interface sound effects' to re-set and your sound should then play ok.
我有同样的问题,并在*上的类似问题中找到了解决方案(但我无法再找到它提供链接) - 我的问题的解决方案是打开我的mac的系统偏好设置并打开声音选项。在“声音”屏幕中,取消选中然后重新检查“播放用户界面音效”以重新设置,然后您的声音就可以正常播放。
#2
0
I had a similar issue. Make sure the target membership is checked in the file inspector tab. Also, remove the app from your phone, do a clean build and then, restart your phone and see if it works.
我有一个类似的问题。确保在文件检查器选项卡中检查目标成员身份。此外,从手机中删除应用程序,进行干净的构建,然后重新启动手机,看看它是否有效。
#1
0
I had the same problem and found a solution in a similar question on * (but I can't find it again to provide the link) - The solution to my problem was to open the System Preferences for my mac and open the Sounds option. In the Sounds screen, uncheck and then re-check the 'Play user interface sound effects' to re-set and your sound should then play ok.
我有同样的问题,并在*上的类似问题中找到了解决方案(但我无法再找到它提供链接) - 我的问题的解决方案是打开我的mac的系统偏好设置并打开声音选项。在“声音”屏幕中,取消选中然后重新检查“播放用户界面音效”以重新设置,然后您的声音就可以正常播放。
#2
0
I had a similar issue. Make sure the target membership is checked in the file inspector tab. Also, remove the app from your phone, do a clean build and then, restart your phone and see if it works.
我有一个类似的问题。确保在文件检查器选项卡中检查目标成员身份。此外,从手机中删除应用程序,进行干净的构建,然后重新启动手机,看看它是否有效。