1

以下代码行可以每周重复一次本地通知,对吗?:

let triggerWeekly = Calendar.current.dateComponents([.weekday,hour,.minute,.second,], from: date)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerWeekly, repeats: true)

但是如何在每个月重复一次本地通知呢?安排每月通知需要哪些日期组件?

4

1 回答 1

2

你可以这样使用:

let triggerMonthly = Calendar.current.dateComponents([.day], from: date)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerMonthly, repeats: true)
于 2017-10-08T19:10:50.740 回答