Skip to main content

DataSync

@ovok/native/data-sync contains the native health authorization and import components for iOS HealthKit and Android Health Connect. The platform provider requests permissions; the matching sync component reads records and writes mapped observations through the active OVOK client.

Start with the HealthKit and Health Connect guide for native setup, data mapping, and an end-to-end flow. Use this page to find the component and type references.

Import the module​

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

The subpath keeps platform health libraries out of apps that do not use health imports. Mount the app under OvokProvider and render sync components only when the client and patient profile are ready.

Components​

ComponentPurpose
DataSyncCompound API that exposes the platform providers, sync components, and manual request sheet as static members.
AppleHealthAuthorizationProviderRequests HealthKit access and reports request state.
AppleHealthSyncImports mapped samples from HealthKit.
AndroidHealthConnectAuthorizationProviderInitializes Health Connect, requests permissions, and refreshes state when the app becomes active.
AndroidHealthSyncImports mapped records from Health Connect.
SyncProgressListRenders per-type status, counts, and progress bars.
ManuallyRequestSheetCompound bottom-sheet UI for an app-owned permission prompt, with six documented subcomponents.

For an adapter-driven permission card, see HealthImportCard. It does not invoke the DataSync provider import pipeline.

Exported types​

The module also exports:

  • AppleHealthSyncProps and AndroidHealthSyncProps;
  • AppleHealthAuthorizationStatus and AndroidHealthConnectAuthorizationStatus;
  • HealthSyncKey, HealthSyncKeys, HealthDataType, and HealthDataMode;
  • SyncProgress and SyncPauseReason;
  • SyncProgressListProps.

Use the platform-specific props type when declaring a reusable mapping:

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

const dataToSync: AppleHealthSyncProps["dataToSync"] = {
// Add only the measurement keys and HealthKit identifiers the feature needs.
};

Runtime behavior​

  • Imports start when the platform sync component mounts.
  • Both platform providers default to requesting access automatically. Pass a manual request renderer and skipRequest={false} when the app owns the prompt.
  • Each sync uses dataToSync to map source identifiers to observation codes.
  • The default provider read chunk is 250 records.
  • Network loss pauses work. wifiOnly can also pause it on cellular data.
  • HealthKit observer delivery and Android headless Health Connect work are configured separately; see background sync.