我有一个有效的通知功能,请参见下文。但是我想添加一个附加选项,例如启动计时器或设置一个由通知事件触发的标志。我该怎么办?
func scheduleNotification() {
let center = UNUserNotificationCenter.current()
let content = UNMutableNotificationContent()
content.title = "Late wake up call"
// Configure the trigger for a 10pm wakeup.
var dateInfo = DateComponents()
dateInfo.hour = 22
dateInfo.minute = 0
let trigger = UNCalendarNotificationTrigger(dateMatching: dateInfo, repeats: true)
// Create the request object.
let request = UNNotificationRequest(identifier: "TimesUp", content: content, trigger: trigger)
center.add(request) { (error : Error?) in
if let theError = error {
print(theError.localizedDescription)
}
}
}
例如,一旦触发通知,我想启动一个计时器,或设置一个标志= true,...