GuidesComponentsDataSyncapple

AppleHealthSync

Read HealthKit samples and save mapped OVOK observations

  • Stable unknown
  • Release candidate since 1.16.1-rc.3
  • Development since 1.16.1-dev.2111+9796905

Render this component inside an AppleHealthAuthorizationProvider 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.

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

Every prop, with its type and description, is listed in the @ovok/native/data-sync API reference.

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.

Last updated on

On this page