UILocalNotification在没有声音的情况下发射

时间:2014-02-18 22:44:47

标签: 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];

那么任何想法? :)

2 个答案:

答案 0 :(得分:1)

您的模拟器可能已静音。

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

答案 1 :(得分:0)

如果通知在应用程序运行时触发,您将听不到声音,您需要离开应用程序才能听到。