In my to-do app, I'm trying to set local notification at the time when dead line date for task have been came, but i can't figure out whats wrong with calendar trigger, interval trigger working ok.
func setupNotifications(id: String, contentTitle: String, contentBody: String, date: Date?) {
center.getNotificationSettings { (settings) in
if (settings.authorizationStatus == .authorized) {
let content = UNMutableNotificationContent()
content.title = contentTitle
content.body = contentBody
content.sound = .default
let newdate = date?.addingTimeInterval(5)
let dateComponents = Calendar.current.dateComponents([.year, .month, .day, .hour, .second], from: newdate!)
let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger)
self.center.add(request)
}
}