I have a loop where I construct UNNotificationRequest instances and add them to the UNUserNotificationCenter. The add method does not generate an error, but neither does it seem to actually add the requests. I have inspected each request generated and they all seem to well formed, each id is unique, each date is unique. Authorization status is granted. I must be missing something. Thank you.
See code:
See code:
Code Block private func generateNotifications(allEntries: [Notifications]) { for oneEntry in allEntries { guard let triggerDate = oneEntry.triggerDate, let id = oneEntry.id else { return } let components = Calendar.current.dateComponents(in: .current, from: triggerDate) let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: false) let content = UNMutableNotificationContent() content.title = "University of XXXXXXX" content.body = "Message body goes here" content.badge = 0 content.sound = .default let request = UNNotificationRequest(identifier: id, content: content, trigger: trigger) UNUserNotificationCenter.current().add(request) { (error) in if let error = error { print(error.localizedDescription) } else { print("Added 1 notification to center") UNUserNotificationCenter.current().getPendingNotificationRequests { (allRequests) in print(allRequests.count) } } } } }