How to save workout route if the watch app exited unexpectly

  Kiến thức lập trình

I’m using HKWorkoutRouteBuider to create route in my watch os app
self.routeBuilder?.insertRouteData(locations, completion: { success, error in })

This is how to insert the locations to the route builder

And when workout session stopped

builder.endCollection(withEnd: date) { [weak self] success, error in
    self?.builder?.finishWorkout(completion: { [weak self] workout, error in
        guard let workout = workout else {
            return
        }
        self?.routeBuilder?.finishRoute(with: workout, metadata: nil, completion: { route, error in
            guard error == nil else {
                return
            }
        }
    }
}

If I killed the app during workout, the workout the synced to healkit in few minutes, but the route is lost. I checked the WorkOutDoors, they can save the route even app was killed

How to acheive the same behavior in WorkOutDoors

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT