Contents

recoverActiveWorkoutSession(completion:)

Recovers an active workout session.

Declaration

func recoverActiveWorkoutSession(completion: @escaping  @Sendable (HKWorkoutSession?, (any Error)?) -> Void)
func recoverActiveWorkoutSession() async throws -> HKWorkoutSession?

Mentioned in

Discussion

If your app crashes during an active workout session, the system calls your extension delegate’s handleActiveWorkoutRecovery() method the next time your app launches. To recover the workout session, call recoverActiveWorkoutSession(completion:) from your extension delegate’s handleActiveWorkoutRecovery() method. HealthKit then attempts to restore the previous workout session, returning either a new session object or an error to the completion block.

As soon as you receive the session object, you must access its builder and set up your data source and delegates again, as described in Start a session.

See Also

Managing workouts