I am building a running workout for Apple Watch and I have a problem to implement an "auto-pause" feature.
If I pause the session with pauseWorkout (which calls pause() and method of HKWorkoutSession) the session never receives the .motionResumed event. All events are disabled during the pause.
If I don't pause the HKWorkoutSession, it's OK to auto-resume the workout, but the session continues to run and the elapsedTime continues to increase during the auto-pause.
What is the solution .
Code Block func workoutSession(_ workoutSession: HKWorkoutSession, didGenerate event: HKWorkoutEvent) { // Auto-pause if event.type == HKWorkoutEventType.motionPaused && workoutSettings.autoPause { print("Auto Pause") pauseWorkout() } if event.type == HKWorkoutEventType.motionResumed && workoutSettings.autoPause { print("Auto Resume") resumeWorkout() } }
If I pause the session with pauseWorkout (which calls pause() and method of HKWorkoutSession) the session never receives the .motionResumed event. All events are disabled during the pause.
If I don't pause the HKWorkoutSession, it's OK to auto-resume the workout, but the session continues to run and the elapsedTime continues to increase during the auto-pause.
What is the solution .