本地通知 – 重复快速间隔3

我想每周重复本地通知,在iOS10之前有repeatInterval ,但我无法find适合在iOS10中重复通知的任何内容。 TimeTriggercalendarTrigger都有重复的真实或错误,我可以在哪里申请重复每周,每天,每月。

谢谢。

尝试这个。

 func scheduleNotification(at date: Date, body: String) { let triggerWeekly = Calendar.current.dateComponents([.weekday,hour,.minute,.second,], from: date) let trigger = UNCalendarNotificationTrigger(dateMatching: triggerWeekly, repeats: true) let content = UNMutableNotificationContent() content.title = "Dont Forget" content.body = body content.sound = UNNotificationSound.default() //content.categoryIdentifier = "todoList" let request = UNNotificationRequest(identifier: "textNotification", content: content, trigger: trigger) UNUserNotificationCenter.current().delegate = self //UNUserNotificationCenter.current().removeAllPendingNotificationRequests() UNUserNotificationCenter.current().add(request) {(error) in if let error = error { print("Uh oh! We had an error: \(error)") } } }