我想使用UNTimeIntervalNotificationTrigger或UNCalendarNotificationTrigger实现定时通知(在iOS 10中),并将repeat参数作为true,连续2-3天。稍后,我可以更新或删除未来几天的通知。例如,我在13 Nov 2017上安排了通知,我想重复这一点,直到早上在10AM的17 Nov 2017,在15 Nov 2017上,我想在接下来的两天(16 Nov和17 Nov)更改通知的计划时间。
因此,您能建议我有哪些替代方案或如何实现这一目标吗?
发布于 2017-11-14 00:52:26
我想你可以使用触发器。
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)要创建符合您需求的dateComponents,您必须执行以下操作:
// Matching specific minute and hour
let unitFlags = Set<Calendar.Component>([.hour, .minute])
dateComponents = NSCalendar.current.dateComponents(unitFlags, from: givenDate)
// Matching specific weekday, hour and minute
let unitFlags = Set<Calendar.Component>([.weekday, .hour, .minute])
dateComponents = NSCalendar.current.dateComponents(unitFlags, from: givenDate)
// Matching specific day, hour and minute
let unitFlags = Set<Calendar.Component>([.day, .hour, .minute])
dateComponents = NSCalendar.current.dateComponents(unitFlags, from: givenDate)https://stackoverflow.com/questions/47269078
复制相似问题