Update:
I needed to find the next notification request and the associated ID so I ended up going with this:
UNUserNotificationCenter.current().getPendingNotificationRequests {
(requests) in
var requestDates = [String:Date]()
for request in requests{
let requestId = request.identifier
let trigger = request.trigger as! UNCalendarNotificationTrigger
let triggerDate = trigger.nextTriggerDate()
requestDates[requestId] = triggerDate
}
let nextRequest = requestDates.min{ a, b in a.value < b.value }
print(String(describing: nextRequest))
}
I thought that this method might provide a more elegant solution but as Duncan pointed out below UNNotificationRequests are not comparable:
requests.min(by: (UNNotificationRequest, UNNotificationRequest) throws -> Bool>)
If anyone has a better solution then let me know.