【发布时间】:2018-10-06 05:17:57
【问题描述】:
我的应用必须每隔 n 天提醒用户某事。
目前,我有
var dateComponents = DateComponents()
dateComponents.hour = userHour
dateComponents.minute = userMinute
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)
我的问题是我不知道如何用 DateComponents 表达跳过日期。
我找到了UNTimeIntervalNotificationTrigger,它允许我每 24 或 48 小时等设置一次,但这让我有可能在特定的白天开火。
我应该混合这两个吗?首先设置日历触发器并在第一个通知中让它实际重复?我觉得不对,一定有更简单的方法。
【问题讨论】:
-
我认为您需要同时使用两者。唯一的问题是用户必须单击第一个通知,才能以正确的时间间隔安排
UNTimeIntervalNotificationTrigger。
标签: swift uilocalnotification nsdatecomponents