当应用程序未运行IOS时播放警报声音

时间:2015-09-17 09:48:40

标签: ios audio notifications alarm

我一直致力于IOS闹钟应用。我将在应用程序中创建一个警报。所以我需要闹钟才能工作,因为"时钟"应用程序在IOS中工作。

当闹钟时间到来且应用未运行时。警报声将播放,用户可以通过单击取消或暂停来停止它。

1 个答案:

答案 0 :(得分:2)

对于您需要使用的警报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没有任何设置暂停的方法:

https://github.com/retsohuang/AlarmClock

https://github.com/bauerjon/Alarm-Clock-iOS