For the count down, I used this code and it solves the problem perfectly.
				.onReceive(NotificationCenter.default.publisher(for: WKExtension.applicationWillResignActiveNotification)) { _ in
						print("Moving to the background")
						notificationDate = Date()
				}
				.onReceive(NotificationCenter.default.publisher(for: WKExtension.applicationDidBecomeActiveNotification)) { _ in
						print("Moving to the foreground")
						let deltaTime: Int = Int(Date().timeIntervalSince(notificationDate))
						timeRemaining -= deltaTime
						percent += Double(deltaTime) / 1.2
				}
But when the count down reaches 0, I need to provide a sort of Haptic Feedback to the user in order to tell him/her that the resting time is over. I have an issue when the watch is in sleep mode (wrist down).
I am thinking on using User Notification for this purpose.
I used a simple test notification with a 5 second timer. It works perfectly when I quit the app before the 5 sec countdown, but not when I stay in the app with a wrist down (to put the watch in sleep mode)
How should I use local notification to work even if I stay in the app in sleep mode?
I am not too familiar with the UserNotifications framework :(
Thanks for your feedback
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: