wip
This commit is contained in:
@@ -45,11 +45,14 @@ class WatchWorkout: NSObject, ObservableObject, HKWorkoutSessionDelegate, HKLive
|
|||||||
|
|
||||||
func startWorkout() {
|
func startWorkout() {
|
||||||
if isInWorkout { return }
|
if isInWorkout { return }
|
||||||
|
setupCore()
|
||||||
hkWorkoutSession.startActivity(with: Date())
|
hkWorkoutSession.startActivity(with: Date())
|
||||||
|
isInWorkout = true
|
||||||
//WKInterfaceDevice.current().play(.start)
|
//WKInterfaceDevice.current().play(.start)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopWorkout(sendDetails: Bool) {
|
func stopWorkout(sendDetails: Bool) {
|
||||||
|
hkWorkoutSession.endCurrentActivity(on: Date())
|
||||||
hkWorkoutSession.end()
|
hkWorkoutSession.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,10 +128,13 @@ class WatchWorkout: NSObject, ObservableObject, HKWorkoutSessionDelegate, HKLive
|
|||||||
}
|
}
|
||||||
|
|
||||||
func workoutSession(_ workoutSession: HKWorkoutSession, didFailWithError error: Error) {
|
func workoutSession(_ workoutSession: HKWorkoutSession, didFailWithError error: Error) {
|
||||||
workoutSession.end()
|
print("[didFailWithError] Workout Builder changed event: \(error.localizedDescription)")
|
||||||
setupCore()
|
// trying to go from ended to something so just end it all
|
||||||
startWorkout()
|
if workoutSession.state == .ended {
|
||||||
beginBuilderWorkout()
|
getWorkoutBuilderDetails(completion: {
|
||||||
|
self.setupCore()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) {
|
func workoutBuilder(_ workoutBuilder: HKLiveWorkoutBuilder, didCollectDataOf collectedTypes: Set<HKSampleType>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user