当应用未运行IOS时播放警报声
我一直在研究IOS报警应用程序。 我将在应用程序中创建一个警报。 所以我需要闹钟作为“时钟”应用程序在IOS中工作。
当闹钟时间到达并且应用程序未运行时。 警报声将播放,用户可以通过单击取消或暂停来停止它。
对于警报,您需要使用UILocalNotification
您可以使用以下应用程序设置警报计划:
- (void)scheduleLocalNotificationWithDate:(NSDate *)fireDate { UILocalNotification *localNotification = [[UILocalNotification alloc] init]; [localNotification setFireDate:fireDate]; [localNotification setAlertBody:@"Time to wake up!"]; [localNotification setSoundName:@"Thunder Song.m4r"]; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; }
这里有两个Github
链接,例如代码或Alarm但是UILocalNotification没有任何设置打盹的方法: