如何重复和结束重复本地通知是iOS 10?

时间:2017-08-18 04:25:57

标签: swift ios10 nscalendar localnotification

系统应用'提醒'可以设置重复和结束重复,但iOS 10 UserNotification.framework不支持此功能。 我使用UNCalendarNotificationTrigger来推送本地通知。如何实现重复和结束重复功能?感谢。

let dateC = Calendar.current.dateComponents([.day, .hour, .minute], from: startDate!)

let trigger = UNCalendarNotificationTrigger(dateMatching: dateC, repeats: true)

let content = UNMutableNotificationContent()
content.title = "title"
content.body = "body"

let request = UNNotificationRequest(identifier: testIdentifier, content: content, trigger: trigger)

center.add(request) { (error) in
    if let error = error {
        print(error)
        return
    }

    print("scheduled")
}

0 个答案:

没有答案