Skip to main content

AndroidHealthSync

Render this component inside an AndroidHealthConnectAuthorizationProvider to import the requested Health Connect record types. It starts the import when mounted and renders no visible UI.

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

<DataSync.AndroidHealthConnectAuthorizationProvider
readIdentifiers={["Weight", "Steps"]}
>
<DataSync.AndroidHealthSync
dataToSync={androidDataToSync}
chunkSize={250}
onProgress={setProgress}
onError={handleSyncError}
/>
</DataSync.AndroidHealthConnectAuthorizationProvider>;

Props​

PropRequiredDefaultDescription
dataToSyncYes—Maps HealthSyncKey values to Health Connect record types and observation codes.
chunkSizeNo250Maximum source records read in a provider page.
wifiOnlyNofalsePause when the device is connected over a non-Wi-Fi network.
onProgressNo—Receive the partial per-key progress map.
onErrorNo—Receive an Error, FHIR Bundle<Resource>, or null.

Each dataToSync value contains typeIdentifiers, an optional minDate, and an optional mode. The same record types must be included in the authorization provider's readIdentifiers and the Android native manifest permissions.

Behavior​

  • The component uses the active OvokClient and patient profile from @ovok/core context. Mount it after both are ready.
  • A first import reads the most recent 30 days by default. Set minDate when the feature needs an earlier initial boundary.
  • Existing observations and Health Connect page tokens guide later reads. Configure client storage if page tokens should survive app restarts.
  • 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.

For imports after the app process stops, use the headless task API in @ovok/native/background-sync rather than mounting this React component in a headless task. The task requires a restored client, patient ID, and mapping.