---
title: "sendToRemoteWorkoutSession(data:completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkworkoutsession/sendtoremoteworkoutsession(data:completion:)"
---

# sendToRemoteWorkoutSession(data:completion:)

Sends the provided data to the remote workout session.

## Declaration

```swift
func sendToRemoteWorkoutSession(data: Data, completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```swift
func sendToRemoteWorkoutSession(data: Data) async throws
```

## Parameters

- `data`: A data object that contains the data your app is sending to the remote workout session.
- `completion`: A block that the system calls when the send attempt is complete. The system passes the following parameters:

## Discussion

Discussion Call this method to send data to your remote workout session. You can send data from either the HKWorkoutSessionType.mirrored or HKWorkoutSessionType.primary session. let archivedData = try? NSKeyedArchiver.archivedData(withRootObject: data, requiringSecureCoding: true) guard let archivedData = archivedData, !archivedData.isEmpty else {     // Handle the error here.     fatalError("*** Encoded data is empty ***") }

// Send the data to the companion iPhone. Task {     do {         try await session.sendToRemoteWorkoutSession(data: archivedData)     }     catch {         // Handle the error here.         fatalError("*** An error occurred while sending the health data to the companion iPhone: \(error.localizedDescription) ***")     } }

## See Also

### Working with remote workout sessions

- [startMirroringToCompanionDevice(completion:)](healthkit/hkworkoutsession/startmirroringtocompaniondevice(completion:).md)
- [stopMirroringToCompanionDevice(completion:)](healthkit/hkworkoutsession/stopmirroringtocompaniondevice(completion:).md)
