How to Run Code at iOS 10 Local Notification Runtime <p>I'm trying to schedule a local notification with a different attachement each day, however the code to find the correct daily attachment seems to run at notification creation rather than runtime, how do I set it to run at runtime. </p> <p>//Setup</p> <pre><code>print("Value of Consts: \(Consts.isGrantedNotificationAccess)") if Consts.isGrantedNotificationAccess { let center = UNUserNotificationCenter.current() center.removeAllPendingNotificationRequests() center.removePendingNotificationRequests(withIdentifiers:[dayRequest]) let content = NotificationContent(title: "Daily Reminder", subTitle: " ", body: " ") let name = Helpers.getImageName() guard let url = Helpers.saveImage(name: "\(name).png") else { print("Error not URL") return } let attachment = try? UNNotificationAttachment(identifier: Consts.imageIdentifier, url: url, options: [:]) if let attachment = attachment { content.attachments.append(attachment) } let hour = DatePicker.calendar.component(.hour, from: DatePicker.date) let minute = DatePicker.calendar.component(.minute, from: DatePicker.date) var dateComponents = DateComponents() dateComponents.hour = hour dateComponents.minute = minute let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true) //set the request let request = UNNotificationRequest(identifier: dayRequest, content: content, trigger: trigger) //add the notification UNUserNotificationCenter.current().add(request) { error in UNUserNotificationCenter.current().delegate = self if (error != nil){ //handle here print(error) } } self.dismiss(animated: true, completion: nil) } </code></pre> <p>The Helper.getImageName() returns an image name based on the date, now the current notification shows the same image each day, as the code runs at notification creation, is there any way to make the code run at notification runtime?</p>