基於此教程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