Contents

workoutSessionMirroringStartHandler

A block that the system calls when it starts a mirrored workout session.

Declaration

var workoutSessionMirroringStartHandler: (@Sendable (HKWorkoutSession) -> Void)? { get set }

Discussion

The system calls this block on the companion iPhone when someone starts a mirrored workout on Apple Watch. If your iOS app isn’t active, the system launches it in the background.

// The HealthKit store calls this closure when Apple Watch starts a remote session.
store.workoutSessionMirroringStartHandler = { mirroredSession in
    // Reset the health data.
    self.data = HealthData()

    // Save a reference to the workout session.
    self.session = mirroredSession
    logger.debug("*** A session started on the companion Apple Watch. ***")
}

To ensure that your app can always catch incoming mirrored workout sessions, assign this property as soon as your app launches.

The system calls this block from an arbitrary background queue.

See Also

Managing workout sessions