i have a timer in swift:
private var timer: Timer?
@objc
private func startBreakTime() {
var count = 90
self.breakTimeButton.isEnabled = false
self.timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] timer in
guard let self = self else {
timer.invalidate()
return
}
count -= 1
self.timerLabel.text = String(format: "%02d:%02d", count / 60, count % 60)
if count == 0 {
self.cancelBreakTimeForCountdown(timer: timer)
self.counterFor += 1
self.handleSeriesMessage()
self.sendNotification()
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
}
}
}
When the interval reaches 0, the user should receive a notification, even if they are using another app. My problem is that my timer and the cell phone are not running together. For testing, I put a timer running, and when it reached 0, mine is still at 55 sec. How can I make my timer keep running, even with the app minimized?
I need to send notification, precisely 1:30 after he touches the button, even if he minimize
I have tried to sync my notification with my timer, but i dont know how