diff --git a/iphone/Werkout_watch Watch App/WatchWorkout.swift b/iphone/Werkout_watch Watch App/WatchWorkout.swift index 78d6e01..be0b59f 100644 --- a/iphone/Werkout_watch Watch App/WatchWorkout.swift +++ b/iphone/Werkout_watch Watch App/WatchWorkout.swift @@ -45,11 +45,14 @@ class WatchWorkout: NSObject, ObservableObject, HKWorkoutSessionDelegate, HKLive func startWorkout() { if isInWorkout { return } + setupCore() hkWorkoutSession.startActivity(with: Date()) + isInWorkout = true //WKInterfaceDevice.current().play(.start) } func stopWorkout(sendDetails: Bool) { + hkWorkoutSession.endCurrentActivity(on: Date()) hkWorkoutSession.end() } @@ -125,10 +128,13 @@ class WatchWorkout: NSObject, ObservableObject, HKWorkoutSessionDelegate, HKLive } func workoutSession(_ workoutSession: HKWorkoutSession, didFailWithError error: Error) { - workoutSession.end() - setupCore() - startWorkout() - beginBuilderWorkout() + print("[didFailWithError] Workout Builder changed event: \(error.localizedDescription)") + // trying to go from ended to something so just end it all + if workoutSession.state == .ended { + getWorkoutBuilderDetails(completion: { + self.setupCore() + }) + } } func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set) {