毎週日曜日の17時に通知が来る処理を実装しております。
以下の記述で次の通知日時(fireDate)は分かるのですが、次以降の全ての通知日時を知るためにはどのようにしたらよいでしょうか。
print(calendarTrigger.nextTriggerDate())
※iOS10になる前は以下の記述で確認しておりました。
UIApplication.shared.scheduledLocalNotifications
※以下の記述では確認できませんでした。
UNUserNotificationCenter.current().getDeliveredNotifications
var components = DateComponents()
components.weekday = 1
components.hour = 17
components.minute = 0
let calendarTrigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: true)
print(calendarTrigger.nextTriggerDate())
let contents = UNMutableNotificationContent()
contents.title = "This is title"
let calendarRequest = UNNotificationRequest(identifier: "test", content: contents, trigger: calendarTrigger)
let center = UNUserNotificationCenter.current()
center.add(calendarRequest)
環境は以下です。
iOS10、Xcode8、Swift3
よろしくお願いいたします。
あなたの回答
tips
プレビュー