UILocalNotification重复间隔不工作

我试图让UILocalNotification每秒重复一次,而且确实是重复的,但由于某种原因,并不是每一秒钟,它似乎都是每分钟重复一次,我还是新的UILocalNotifications,所以我可能做错了什么。 这里有一个notifs的图片: http ://imgur.com/Hzt38py

这是我用来创buildUILocalNotification的函数

func notificationCreater (date:NSDate, uuid:String) { let notification = UILocalNotification () notification.alertBody = "Test Run 9" notification.fireDate = date notification.repeatInterval = NSCalendarUnit.CalendarUnitSecond //notification.userInfo = ["UUID": uuid] // notification.soundName = "alarmSound.m4a" // notification.alertAction = "he" // notification.soundName = "alarmSound.m4a" // notification.alertTitle = "Test Title" println("schld") UIApplication.sharedApplication().scheduleLocalNotification(notification) } 

这是View Controller的其余部分

 class AddTaskViewController: UIViewController,AVAudioPlayerDelegate{ @IBOutlet weak var taskTextField: UITextField! @IBOutlet weak var dueDatePicker: UIDatePicker! var delegate = AddTaskViewControllerDelegate?() override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = UIColor(patternImage: UIImage(named: "Background")!) // Do any additional setup after loading the view. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func cancelButtonTapped(sender: UIButton) { self.dismissViewControllerAnimated(true, completion: nil) delegate?.addTaskCanceled!("task canceled") UIApplication.sharedApplication().cancelAllLocalNotifications() } @IBAction func addTaskButtonTapped(sender: UIButton) { let appDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate) let managedObjectContext = appDelegate.managedObjectContext let entityDescription = NSEntityDescription.entityForName("TaskModel", inManagedObjectContext: managedObjectContext!) let task = TaskModel(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext!) task.task = taskTextField.text task.date = dueDatePicker.date task.uuid = NSUUID().UUIDString //if NSUserDefaults.standardUserDefaults().boolForKey(kShouldCompleteNewTodoKey) == true {task.completed = true} task.completed = false appDelegate.saveContext() let calendar = NSCalendar.currentCalendar() let comp = calendar.components(NSCalendarUnit.CalendarUnitSecond, fromDate: task.date) let seconds = Double(comp.second) // let notification = UILocalNotification() // notification.alertBody = "testBody" // notification.fireDate = dueDatePicker.date // notification.alertTitle = "testTitle" println("seconds:\(seconds)") var request = NSFetchRequest(entityName: "TaskModel") var error:NSError? = nil var results:NSArray = managedObjectContext!.executeFetchRequest(request, error: &error)! notificationCreater(dueDatePicker.date, uuid: task.uuid) self.dismissViewControllerAnimated(true, completion: nil) } 

通知是在添加任务button被单击时创build的,但不会每秒重复一次。 我究竟做错了什么?

**即使手机处于“请勿打扰”或静音模式,也有人知道如何播放通知声音

从苹果的文档repeatInterval

如果您指定日历单位(如每周(NSWeekCalendarUnit)或每年(NSYearCalendarUnit)),则系统将按照指定的时间间隔重新计划通知以进行投放。 请注意,不足一分钟的时间间隔不受支持。 默认值是0,这意味着系统会触发一次通知,然后丢弃它。

应用程序应该在后台触发通知。 如果要在应用程序处于前台时触发通知,则还要执行

 func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification){ 

}