GuidesComponentsDataSyncapple

AppleHealthAuthorizationProvider

Request HealthKit permissions and expose authorization state

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

Wrap the HealthKit screen with this provider to request access to selected HealthKit sample types. It can request access automatically or render the app-provided permission UI. Its children include the screen's health sync only after the provider's request flow is ready.

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

<DataSync.AppleHealthAuthorizationProvider
  readIdentifiers={["HKQuantityTypeIdentifierBodyMass"]}
  fallback={<ActivityIndicator />}
  onAuthorizationStatusChange={setHealthKitStatus}
>
  <DataSync.AppleHealthSync dataToSync={appleDataToSync} />
</DataSync.AppleHealthAuthorizationProvider>;

Props

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

Status

AppleHealthAuthorizationStatus contains:

  • state: unknown, shouldRequest, requesting, ready, or error;
  • notRequestedReadIdentifiers: requested read types still awaiting an answer;
  • notRequestedWriteIdentifiers: requested write types still awaiting an answer;
  • optional error when the request or status inspection fails.

HealthKit does not reveal whether a person denied read access to a type. A ready state means the provider no longer has a request pending; it does not prove every requested type is readable. Treat empty reads as a valid result.

The provider can filter read identifiers still reported as unanswered so one unanswered type does not prevent syncing other configured types. Keep the readIdentifiers aligned with the identifiers in dataToSync.

Native setup

Enable the HealthKit capability and add the app's NSHealthShareUsageDescription. Add the write usage description and HealthKit write setup only if the app writes to HealthKit. See installation and native setup and the HealthKit and Health Connect guide.

Last updated on

On this page