I can get the next notification with the following code:
let center = UNUserNotificationCenter.current()
center.getPendingNotificationRequests { (notifications) in
let pendingNotifications : [UNNotificationRequest] = notifications
let notification = pendingNotifications[0]
let trigger = notification.trigger
let content = notification.content
}
trigger
gets me:
<UNCalendarNotificationTrigger: 0x6000004319e0; dateComponents: <NSDateComponents: 0x60000014f570>
Hour: 16
Minute: 10
Second: 0, repeats: YES>
But I can't call trigger.dateComponents
How do I get this date?
You want to use dateComponents
of the UNCalendarNotificationTrigger
. try using notification.fireDate
to retrieve that.
More info on Apple Developer Documentation: https://developer.apple.com/documentation/usernotifications/uncalendarnotificationtrigger