基于此教程Simple iOS Alarm Clock Tutorial我实现了AlarmClock应用程序。 通知功能正常,但没有声音。LocalNotification - ios 7.1模拟器上的UILocalNotificationDefaultSoundName不起作用
为了解决这个问题,我尝试过: Fix-1并取消选中/检查了我的MacOS声音设置。
我能做些什么来获得简单的AlarmClock声音? (信息:YouTube的声音作品@模拟器)
代码:
-(void)scheduleLocalNotificationWithDate:(NSDate *)fireDate
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
UILocalNotification *notification = [UILocalNotification new];
notification.fireDate = fireDate;
notification.soundName = UILocalNotificationDefaultSoundName;
notification.alertBody = @"Wake-up... !!!";
notification.alertAction = @"OK";
//[notification setApplicationIconBadgeNumber:-1];
notification.applicationIconBadgeNumber = 1; // increment
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
你是对的!干杯 – blub