First off I am not very familiar with do statements but I think they can be used just like a action button. My code below is a alarm. All I wanted to do is when the alarm goes off for the notification to appear. Thats it. Right now the alarm goes off (successT is printed in log file) the notification does not appear.
override func viewDidLoad() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.sound,.badge]) { (didAllow, error) in
}
}
@objc func testDate() {
if Calendar.current.isDate(datePicker.date, equalTo: Date(), toGranularity: .minute) {
print("successT")
passingDate = datePicker.date
do {
let content = UNMutableNotificationContent()
content.title = "3 seconds are up"
content.badge = 1
content.subtitle = "d"
content.body = "theBody"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger )
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
}
}
}