Hi, I'm developing a Live Activity Widget that shows a count down timer. In the current solution I have a stop watch that is responsible for handling the start, stop, resume, reset function. When the stop watch starts I have timer that calls on an updateTime function every 0.2 seconds. This works well. The problems comes when I try to use my stop watch in the Live Activity Widget. I have a timer that updates the live activity attributes with content every 0.5 second.
// Start the activity
let activity = try? Activity.request(...
DispatchQueue.main.async {
self.logger.log("Start internal timer")
self.timer = Timer.scheduledTimer(withTimeInterval:0.5, repeats: true) { _ in
self.logger.log("Update activity widget.")
self.updateActivity()
}
}
Is this a correct approach? If not what should I use to implement a stop watch with a count down timer and a corresponding progress bar/view?