我一直在开发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
链接,用于示例代码或警报,但 UILocalNotification 没有任何设置贪睡的方法:
关于ios - 当应用程序未运行 IOS 时播放警报声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32627322/