# AppleHealthSync

Canonical page: https://docs.ovok.com/native-sdk/guide/components/data-sync/apple/health-sync

Render this component inside an
[`AppleHealthAuthorizationProvider`](/native-sdk/guide/components/data-sync/apple/health-authorization-provider/) to import
the HealthKit types requested by the screen. It starts the initial sync when
mounted, watches for HealthKit changes, and reports progress through callbacks.
It renders no visible UI.

~~~tsx
import { DataSync } from "@ovok/native/data-sync";

<DataSync.AppleHealthAuthorizationProvider
  readIdentifiers={["HKQuantityTypeIdentifierBodyMass"]}
>
  <DataSync.AppleHealthSync
    dataToSync={appleDataToSync}
    chunkSize={250}
    wifiOnly
    onProgress={setProgress}
    onError={handleSyncError}
  />
</DataSync.AppleHealthAuthorizationProvider>;
~~~

## Props [#props]

Every prop, with its type and description, is listed in the [`@ovok/native/data-sync` API reference](/native-sdk/reference/data-sync).

## Behavior [#behavior]

- The component uses the active native `Ovok` client and Patient session from
  `@ovok/core/next/react` context. Mount it after sign-in.
- A first import reads the most recent 30 days by default. Set `minDate` when
  the feature needs an earlier initial boundary.
- Existing observations and HealthKit query anchors guide later reads. The native
  client's secure storage keeps anchors across app restarts per patient and project.
- Progress updates include `idle`, `started`, `syncing`, `paused`,
  `failed`, or `completed`; pause reasons are `offline` and `wifi-only`.
- Offline connectivity pauses the service. `wifiOnly` also pauses it on
  cellular, then the service resumes when the network meets the policy.

`backgroundDelivery={{ frequency }}` enables HealthKit observer delivery for
each mapped identifier. The default frequency is hourly. Add the HealthKit
background capability in the native config and rebuild the app. iOS decides when
observer work runs; the option is not a fixed schedule.

Keep `AppleHealthSync` mounted while the app should receive observer updates. When
the component unmounts, it removes the subscriptions and disables background
delivery for the mapped identifiers.

HealthKit does not expose read-denial state. Empty sample results do not necessarily
mean that the import configuration is wrong.

## Related [#related]

- [HealthKit authorization provider](/native-sdk/guide/components/data-sync/apple/health-authorization-provider/)
- [SyncProgressList](/native-sdk/guide/components/data-sync/sync-progress-list/)
- [HealthKit and Health Connect guide](/native-sdk/guide/modules/data-sync)
- [Background sync](/native-sdk/guide/modules/background-sync)
