我正在实现一个自定义的重复提醒,如默认提醒应用程序。在这里,我不知道如何设置每N天/周/月/年的重复间隔like Trigger,即,从现在起每第4天/周/月/年触发通知。
下面是我对interval =1的实现
if type == .daily{
dateComponents = Calendar.current.dateComponents([.hour, .minute], from: Date())
}else if type == .weekly{
dateComponents = Calendar.current.dateComponents([.hour, .minute,.weekday], from: Date())
}else if type == .monthly{
dateComponents = Calendar.current.dateComponents([.day,.hour, .minute], from: Date())
}else if type == .yearly{
dateComponents = Calendar.current.dateComponents([.hour, .minute,.day,.month], from: Date())
}发布于 2019-07-02 22:11:42
不幸的是,UNNotificationRequest没有为本地通知设置自定义重复间隔的接口。
看起来,你的问题没有稳定的工作解决方案,但作为一种变通方法,你可以尝试通过基于重复间隔请求多个本地通知(使用UNTimeIntervalNotificationTrigger),然后在每次应用程序开始运行时重新安排新的通知,来实现自定义的重新安排逻辑。
https://stackoverflow.com/questions/56852790
复制相似问题