@ovok/native/data-sync

Apple Health and Health Connect import: authorization, sync progress and manual request UI.

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

Apple Health and Health Connect import: authorization, sync progress and manual request UI.

Import from @ovok/native/data-sync.

Components

SyncProgressList

const SyncProgressList: MemoExoticComponent<(__namedParameters) => Element>;

Lists the sync progress of each data type with its status.


DataSync()

function DataSync(__namedParameters): Element;

Namespace for the health data sync components; renders its children.

Parameters

ParameterType
__namedParameters{ }

Returns

Element

Hooks

useHealthAuthorization()

function useHealthAuthorization(): HealthAuthorizationValue;

Returns the health authorization state; must be used inside an Apple Health or Health Connect authorization provider.

Returns

HealthAuthorizationValue

Classes

HealthSyncBatchError

Error of a health import batch that did not save every entry, carrying the server response.

Extends

  • Error

Constructors

Constructor
new HealthSyncBatchError(
   message,
   bundle?,
   outcome?
): HealthSyncBatchError;
Parameters
ParameterTypeDescription
messagestring-
bundle?Bundle<Resource>Transaction response bundle of the batch that failed to save every entry.
outcome?OperationOutcomeOperation outcome the server returned for the batch.
Returns

HealthSyncBatchError

Overrides

Error.constructor

Properties

PropertyModifierTypeDefault valueDescriptionOverrides
bundle?public readonlyBundle<Resource>undefinedTransaction response bundle of the batch that failed to save every entry.-
namepublic readonly"HealthSyncBatchError""HealthSyncBatchError"Error name.Error.name
outcome?public readonlyOperationOutcomeundefinedOperation outcome the server returned for the batch.-

Functions

getHealthDataCoding()

function getHealthDataCoding(
   provider,
   identifier,
   mode
): object;

Returns the coding for a health platform identifier and data mode.

Parameters

ParameterType
providerHealthProvider
identifierstring
modeHealthDataMode

Returns

NameTypeDescription
codestringCode of the coding.
display?stringHuman readable name of the code, when known.
systemstringCode system of the coding.

getHealthDataMode()

function getHealthDataMode(key, configuredMode?): HealthDataMode;

Returns the configured mode, or the default mode of the data type.

Parameters

ParameterType
keyHealthSyncKey
configuredMode?HealthDataMode

Returns

HealthDataMode


toHealthSyncError()

function toHealthSyncError(error): Error;

Converts a failed batch response or error into an Error, keeping the bundle or outcome.

Parameters

ParameterType
errorunknown

Returns

Error

Type Aliases

AndroidHealthConnectAuthorizationStatus

type AndroidHealthConnectAuthorizationStatus = object;

Health Connect authorization state.

Properties

backgroundAccess?
backgroundAccess?: "authorized" | "shouldRequest" | "refused" | "unsupported";

Background access is reported independently; it never blocks foreground import.

error?
error?: Error;

Error of the last authorization attempt.

missingTypes?
missingTypes?: readonly string[];

Record types that still need authorization.

state
state:
  | "unknown"
  | "shouldRequest"
  | "requesting"
  | "authorized"
  | "refused"
  | "error";

Current authorization stage.


AndroidHealthSyncProps

type AndroidHealthSyncProps = HealthSyncProps<RecordType>;

Props of AndroidHealthSync.


AppleHealthAuthorizationStatus

type AppleHealthAuthorizationStatus = object;

Apple Health authorization state.

Properties

error?
error?: Error;

Error of the last authorization attempt.

notRequestedMeasurementTypes
notRequestedMeasurementTypes: HealthSyncKey[];

Configured measurement types with at least one unanswered read identifier.

notRequestedReadIdentifiers
notRequestedReadIdentifiers: AppleHealthDataTypeIdentifier[];

HealthKit types that still need to be answered in Settings.

notRequestedWriteIdentifiers
notRequestedWriteIdentifiers: SampleTypeIdentifierWriteable[];

HealthKit write types that still need to be answered in Settings.

state
state: "unknown" | "shouldRequest" | "requesting" | "ready" | "error";

Current authorization stage.


AppleHealthDataTypeIdentifier

type AppleHealthDataTypeIdentifier = SampleTypeIdentifier;

HealthKit sample type identifiers supported by the SDK.


AppleHealthSyncProps

type AppleHealthSyncProps = HealthSyncProps<AppleHealthDataTypeIdentifier> & object;

Props of AppleHealthSync.

Type Declaration

NameTypeDescription
backgroundDelivery?objectEnables HealthKit observer delivery while the app is in the background.
backgroundDelivery.frequency?UpdateFrequencyHow often HealthKit delivers updates in the background.

HealthAuthorizationValue

type HealthAuthorizationValue =
  | {
  missingTypes: readonly string[];
  platform: "apple-health";
  request: () => Promise<void>;
  status: AppleHealthAuthorizationStatus;
}
  | {
  missingTypes: readonly string[];
  platform: "health-connect";
  request: () => Promise<void>;
  status: AndroidHealthConnectAuthorizationStatus;
};

Authorization state and request action of the active health platform.

Union Members

Type Literal
{
  missingTypes: readonly string[];
  platform: "apple-health";
  request: () => Promise<void>;
  status: AppleHealthAuthorizationStatus;
}
NameTypeDescription
missingTypesreadonly string[]Data types that have not been authorized.
platform"apple-health"Apple Health platform.
request()() => Promise<void>Requests the missing authorizations.
statusAppleHealthAuthorizationStatusAuthorization status.

Type Literal
{
  missingTypes: readonly string[];
  platform: "health-connect";
  request: () => Promise<void>;
  status: AndroidHealthConnectAuthorizationStatus;
}
NameTypeDescription
missingTypesreadonly string[]Data types that have not been authorized.
platform"health-connect"Health Connect platform.
request()() => Promise<void>Requests the missing authorizations.
statusAndroidHealthConnectAuthorizationStatusAuthorization status.

HealthDataMode

type HealthDataMode = "point" | "daily-total" | "daily-summary" | "session" | "series";

How a data type is turned into observations.


HealthSyncKey

type HealthSyncKey = HealthSyncKeys | HealthDataType;

Measurement type or health-only data type that can be synced.


HealthSyncKeys

type HealthSyncKeys = Exclude<MeasurementTypeKey,
  | MeasurementTypeKey.photoUpload
| MeasurementTypeKey.symptomQuestionnaire>;

Measurement types that can be synced, excluding photo upload and symptom questionnaire.


SyncPauseReason

type SyncPauseReason = "offline" | "wifi-only";

Why a sync is paused.


SyncProgress

type SyncProgress = object;

Sync state of one data type.

Properties

measurementTypeKey
measurementTypeKey: HealthSyncKey;

Data type being synced.

progress?
progress?: object;

Records processed so far.

created?
created?: number;

Number of observations created instead of matched or updated.

done
done: number;

Records processed.

total
total: number;

Records to process.

reason?
reason?: SyncPauseReason;

Why the sync is paused.

status
status: "started" | "completed" | "failed" | "idle" | "syncing" | "paused";

Current sync stage.


SyncProgressListProps

type SyncProgressListProps = object;

Props of SyncProgressList.

Properties

labelForType?
labelForType?: (type) => string;

Returns the display label of a data type.

Parameters
ParameterType
typestring
Returns

string

progress
progress:
  | Partial<Record<string, SyncProgress>>
  | null
  | undefined;

Sync progress per data type.

reasonLabels?
reasonLabels?: Partial<Record<NonNullable<SyncProgress["reason"]>, string>>;

Overrides the pause reason texts.

statusLabels?
statusLabels?: Partial<Record<SyncProgress["status"], string>>;

Overrides the status texts.

Text?
Text?: React.ComponentType<React.ComponentProps<typeof PaperText>>;

Text component used to render labels.

Enumerations

HealthDataType

Health data that is not represented by a core measurement service.

Enumeration Members

Enumeration MemberValueDescription
activeEnergy"active-energy"Active energy burned.
bloodAlcohol"blood-alcohol"Blood alcohol content.
bodyFatPercentage"body-fat-percentage"Body fat percentage.
bodyMassIndex"body-mass-index"Body mass index.
caloriesEaten"calories-eaten"Food energy eaten.
carbohydrates"carbohydrates"Carbohydrates eaten.
distance"distance"Distance walked or run.
exerciseMinutes"exercise-minutes"Minutes of exercise.
flightsClimbed"flights-climbed"Flights of stairs climbed.
heartRateSummary"heart-rate-summary"Summary of heart rate over a period.
height"height"Body height.
insulin"insulin"Insulin delivered.
leanBodyMass"lean-body-mass"Lean body mass.
sleep"sleep"Sleep sessions.
water"water"Water drunk.
workout"workout"Workout sessions.

Variables

HEALTH_DATA_CATALOG

const HEALTH_DATA_CATALOG: readonly HealthDataCatalogEntry[];

Supported Apple Health and Health Connect data types with their LOINC mappings.


HealthAuthorizationContext

const HealthAuthorizationContext: Context<HealthAuthorizationValue | null>;

Context carrying the health authorization state.

References

HealthImportAdapter

Re-exports HealthImportAdapter


useHealthImport

Re-exports useHealthImport

Last updated on

On this page