I'm trying to reset a UNTimeIntervalNotificationTrigger
to sent a notification multiple times. I've tried a few things, including:
-Set repeats: true
-> This crashes my application somehow, giving me the error thread 1 signal sigabrt
Now the problem with the current code (see below) is that I get the error: Use of unresolved identifier 'trigger'
. Now for as far as I understand this error shows me that I can't use trigger because it is set in a button 'function' and that it can't find let trigger
.
Question: How do I make the function resetTimer see trigger
? Or is there a better way to reset UNTimeIntervalNotificationTrigger?
@IBAction func change(_ sender: Any) {
func startTimer() {
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(tijd), repeats: false)
let request = UNNotificationRequest(identifier: bezigheid, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
}
}
func resetTimer() {
trigger.invalidate
}