> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spikeapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# React Native SDK Plugin Expo

> Using Expo plugin with Spike SDK for React Native in your project.

Use the [Expo config plugin](https://docs.expo.io/guides/config-plugins/) to configure the Spike SDK for React Native apps.

## Expo Installation

<Warning>
  This package cannot be used in the "Expo Go" app because [it requires custom native code](https://docs.expo.dev/workflow/customizing/).
</Warning>

The plugin automatically configures both iOS and Android platforms for the Spike SDK. You can find more information
about what is being setup in [React Native setup guide](/sdk-docs/rn/setup).

First install the package with yarn, npm or [`npx expo install`](https://docs.expo.dev/more/expo-cli/#installation).

```sh theme={null}
yarn install react-native-spike-sdk
```

After installing this npm package, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:

```json theme={null}
{
  "expo": {
    "plugins": [
      [
        "react-native-spike-sdk",
        {
          "ios": {
            "healthSharePermission": "Custom health share permission",
            "healthUpdatePermission": "Custom health update permission",
            "isBackgroundDeliveryEnabled": true
          },
          "android": {
            "isBackgroundDeliveryEnabled": true,
            "healthConnectPermissions": [
              "android.permission.health.READ_STEPS",
            ]
          }
        }
      ]
    ]
  }
}
```

Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.dev/workflow/customizing/) guide.

## API

The plugin provides configuration options for both iOS and Android platforms. Every time you change the configuration or plugins, you'll need to rebuild (and `prebuild`) the native app. If no extra properties are added, defaults will be used.

### iOS Configuration

* `healthSharePermission` (*string*): Sets the iOS `NSHealthShareUsageDescription` permission message to the `Info.plist`. Defaults to `Allow $(PRODUCT_NAME) to check health info`.
* `healthUpdatePermission` (*string*): Sets the iOS `NSHealthUpdateUsageDescription` permission message to the `Info.plist`. Defaults to `Allow $(PRODUCT_NAME) to update health info`.
* `isBackgroundDeliveryEnabled` (*boolean*): Adds `com.apple.developer.healthkit.background-delivery` entitlement to the iOS project. Defaults to `true`.

### Android Configuration

* `isBackgroundDeliveryEnabled` (*boolean*): Whether to enable background health data deliveries. Defaults to `true`.
* `healthConnectPermissions` (*string\[]*): Array of Health Connect Android permissions to add to the manifest. Defaults to `[]`.

Extensive list of available permissions:

```text theme={null}
android.permission.health.READ_NUTRITION
android.permission.health.READ_ACTIVE_CALORIES_BURNED
android.permission.health.READ_TOTAL_CALORIES_BURNED
android.permission.health.READ_STEPS
android.permission.health.READ_DISTANCE
android.permission.health.READ_ELEVATION_GAINED
android.permission.health.READ_RESTING_HEART_RATE
android.permission.health.READ_HEART_RATE_VARIABILITY
android.permission.health.READ_FLOORS_CLIMBED
android.permission.health.READ_BASAL_METABOLIC_RATE
android.permission.health.READ_SLEEP
android.permission.health.READ_HEART_RATE
android.permission.health.READ_EXERCISE
android.permission.health.READ_SPEED
android.permission.health.READ_POWER
android.permission.health.READ_OXYGEN_SATURATION
android.permission.health.READ_BLOOD_GLUCOSE
android.permission.health.READ_RESPIRATORY_RATE
android.permission.health.READ_WEIGHT
android.permission.health.READ_HEIGHT
android.permission.health.READ_BODY_FAT
android.permission.health.READ_LEAN_BODY_MASS
android.permission.health.READ_BODY_WATER_MASS
android.permission.health.READ_BODY_TEMPERATURE
android.permission.health.READ_BLOOD_PRESSURE
android.permission.health.READ_BONE_MASS
```

## Capabilities

This plugin will enable the iOS `com.apple.developer.healthkit` entitlement, but to sync this with the bundle identifier's production capabilities you'll need to do one of two things:

* Automatic: Build the app with [EAS build](https://docs.expo.io/build/introduction/)
* Manual: Visit [Apple developer portal](https://developer.apple.com/account/resources/identifiers/list) and enable the HealthKit capability for your bundle identifier before building for production. This can also be done via Xcode.
