# AppleHealthAuthorizationProvider

Canonical page: https://docs.ovok.com/native-sdk/guide/components/data-sync/apple/health-authorization-provider

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.

~~~tsx
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 [#props]

Every prop, with its type and description, is listed in the [`@ovok/native/data-sync` API reference](/native-sdk/reference/data-sync).

## Status [#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 [#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](/native-sdk/guide/how-to/installation) and the
[HealthKit and Health Connect guide](/native-sdk/guide/modules/data-sync).
