For my app I am looking to implement a local notification system.
My code to schedule a notification is as follows:
func scheduleNotification(_ Name:String, _ Time:DateComponents){
let center = UNUserNotificationCenter.current()
let notification = UNMutableNotificationContent()
notification.title = Name
notification.sound = UNNotificationSound.default()
var trigger = UNCalendarNotificationTrigger(dateMatching: Time, repeats: false)
let identifier = Name
let request = UNNotificationRequest(identifier: identifier, content: notification, trigger: trigger)
center.add(request)
}
Now that worked yesterday, but not it no longer does. In both simulator and device.
I've tried the suggestion here to no avail: Local Notifications make sound but do not display (Swift)
What I have tried:
- Testing with the app force closed
- Testing with the app in the background
- Changing identifiers