ios - UILocalNotifications 触发时没有声音

标签 ios objective-c notifications uilocalnotification audio

嗯,发出本地通知,一切都很好,但即使我将声音名称属性设置为默认通知声音名称,也没有声音。 P.S:声音在模拟器和设备上都不起作用。

这是我的代码..

UILocalNotification *aNotification = [[UILocalNotification alloc] init];
                aNotification.timeZone = [NSTimeZone defaultTimeZone];
                aNotification.alertBody = _reminderTitle.text;
                aNotification.alertAction = @"Show me!";
                aNotification.soundName = UILocalNotificationDefaultSoundName;
                aNotification.applicationIconBadgeNumber += 1;

[[UIApplication sharedApplication] scheduleLocalNotification:aNotification];

有什么想法吗? :)

最佳答案

您的模拟器可能已静音。

转到系统偏好设置 -> 声音 -> 音效 -> 选中“播放用户界面音效”

关于ios - UILocalNotifications 触发时没有声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21867110/

相关文章:

ios - 始终锁定 iPhone 应用程序方向

ios - 如何更改 UIPickerView 选择器的颜色

ios - 如何强制 HKQuery 加载最近的步数?

ios - Swift 桥接头 - 新目标

ios - 在 Swift 中向通知添加 if 语句

android - Android 通知操作按钮中的图标大小是多少?

ios - 如何从属于 UIPageViewController 一部分的 UIViewController 之一内更改 UIPageViewController?

iphone - 位置管理器 :didUpdateLocations: always be called several times

objective-c - 在调试器中打印一个字符串显示它的地址,而不是它的内容

notifications - 设备 token 已过期或应用程序已从通知中取消注册