Ios 当应用程序处于后台时,安排音频通知

Ios 当应用程序处于后台时,安排音频通知,ios,Ios,我正在开发类似navi的应用程序 我必须在预定时间播放声音通知。我已经启用了音频背景模式,但显然我无法使用NSTimer进行此操作 我可以使用什么来安排在指定时间的音频通知,这样即使应用程序进入后台也会触发?您可以使用UILocalNotification执行此任务。您可以使用UILocalNotification执行此任务。您需要探索,使用它,您可以设置特定间隔的通知,也可以为您的应用程序设置自定义声音和文件 像 注意:上面的代码属于您需要探索的,使用它您可以设置特定间隔的通知,也可以为您的应

我正在开发类似navi的应用程序

我必须在预定时间播放声音通知。我已经启用了音频背景模式,但显然我无法使用
NSTimer
进行此操作


我可以使用什么来安排在指定时间的音频通知,这样即使应用程序进入后台也会触发?

您可以使用
UILocalNotification
执行此任务。

您可以使用
UILocalNotification
执行此任务。

您需要探索,使用它,您可以设置特定间隔的通知,也可以为您的应用程序设置自定义声音和文件

注意:上面的代码属于您需要探索的

,使用它您可以设置特定间隔的通知,也可以为您的应用程序设置自定义声音、文件

注:以上代码计入

UILocalNotification *notif = [[UILocalNotification alloc] init];
NSDateComponents *dateComp = [[NSDateComponents alloc] init];
[dateComp setDay:YourDay];
[dateComp setHour:YourHour];
[dateComp setMinute:YourMinute];

NSLog(@"Year: %i, Month: %i, Day: %i, Time:%i:%i\n",[dateComp year], [dateComp month], 
                    [dateComp day], [dateComp hour], [dateComp minute]);
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
notif.fireDate = [gregorian dateFromComponents:dateComp];
notif.timeZone = [NSTimeZone defaultTimeZone];

notif.alertBody = YourAlertBody;
notif.soundName = @"fireburn.caf";