Skip to main content

AndroidHealthConnectAuthorizationProvider

Wrap an Android import screen with this provider to initialize Health Connect, request the record permissions the feature needs, and re-check access whenever the app returns to the foreground.

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

<DataSync.AndroidHealthConnectAuthorizationProvider
readIdentifiers={["Weight", "Steps"]}
fallback={<ActivityIndicator />}
onAuthorizationStatusChange={setHealthConnectStatus}
>
<DataSync.AndroidHealthSync dataToSync={androidDataToSync} />
</DataSync.AndroidHealthConnectAuthorizationProvider>;

Props​

PropRequiredDescription
readIdentifiersYesHealth Connect record types the feature reads.
writeIdentifiersNoRecord types the app writes. Omit for read-only import.
backgroundAccessNoAlso request Health Connect's separate background-read permission.
fallbackNoReact content for permission and initialization states.
renderManualRequestUINoRender callback receiving the provider's requestAccess function. Use together with skipRequest.
skipRequestNoRequired when renderManualRequestUI is supplied. Set false to render your request UI; true bypasses the provider's request gate and renders children.
onAuthorizationStatusChangeNoReceives an AndroidHealthConnectAuthorizationStatus update.

Without the manual request props, the provider asks for access automatically when one or more requested permissions are missing. The two manual props form a TypeScript discriminated union: provide both or omit both.

Status​

The root state can be unknown, shouldRequest, requesting, authorized, refused, or error. An optional error explains initialization or permission failures.

When backgroundAccess is true, the separate backgroundAccess status can be authorized, shouldRequest, refused, or unsupported. Background access is independent of foreground permissions; declining it does not block foreground reads.

Use the status callback to distinguish a missing permission from unavailable Health Connect. Declare the matching Android manifest permissions as part of the native build; runtime requests cannot add missing manifest declarations.

Native setup​

Enable the SDK's healthConnect config plugin and add only the android.permission.health.READ_* and optional WRITE_* permissions that match the configured record types. For scheduled background imports, also configure the Android background service and headless task described in background sync.

See installation and native setup and the HealthKit and Health Connect guide.