# Setup & installation

## Get an API key

Email [info@stickyhealth.com](mailto:info@stickyhealth.com) to register your organization. We issue the API key your app passes to `MiriAppProvider`.

## Installation

### Prerequisites

- A React Native development environment. See [Set up your environment](https://reactnative.dev/docs/environment-setup).
- Access to the package. Send us the npm account that will install it and we will grant access.

### Install the SDK and its peer dependencies

The SDK is published to npm as `@miri-ai/miri-react-native`. It relies on the peer dependencies below, which your app must install itself. Every app needs all of them: there is no separate list for Expo or bare React Native apps.

```bash
# npm
npm install @miri-ai/miri-react-native @kingstinct/react-native-healthkit @react-native-async-storage/async-storage @react-native-community/blur @react-native-community/datetimepicker @react-native-picker/picker @shopify/react-native-skia expo-application expo-blur expo-camera expo-crypto expo-device expo-file-system expo-image-picker expo-local-authentication expo-secure-store lottie-react lottie-react-native react-native-device-info react-native-fast-confetti react-native-fs react-native-health-connect react-native-image-picker react-native-keyboard-controller react-native-linear-gradient react-native-picker-select react-native-reanimated react-native-safe-area-context react-native-svg react-native-vision-camera react-native-webview

# Yarn
yarn add @miri-ai/miri-react-native @kingstinct/react-native-healthkit @react-native-async-storage/async-storage @react-native-community/blur @react-native-community/datetimepicker @react-native-picker/picker @shopify/react-native-skia expo-application expo-blur expo-camera expo-crypto expo-device expo-file-system expo-image-picker expo-local-authentication expo-secure-store lottie-react lottie-react-native react-native-device-info react-native-fast-confetti react-native-fs react-native-health-connect react-native-image-picker react-native-keyboard-controller react-native-linear-gradient react-native-picker-select react-native-reanimated react-native-safe-area-context react-native-svg react-native-vision-camera react-native-webview
```

`react` and `react-native` are left out of the command because your app already has them. Several peers contain native code, so rebuild the iOS and Android apps after installing.

#### Peer dependencies

This table is generated from the SDK's `package.json`.

| Package | Version |
| :--- | :--- |
| `@kingstinct/react-native-healthkit` | `>=13.0.0` |
| `@react-native-async-storage/async-storage` | `*` |
| `@react-native-community/blur` | `*` |
| `@react-native-community/datetimepicker` | `*` |
| `@react-native-picker/picker` | `*` |
| `@shopify/react-native-skia` | `*` |
| `expo-application` | `*` |
| `expo-blur` | `*` |
| `expo-camera` | `*` |
| `expo-crypto` | `*` |
| `expo-device` | `*` |
| `expo-file-system` | `*` |
| `expo-image-picker` | `*` |
| `expo-local-authentication` | `*` |
| `expo-secure-store` | `*` |
| `lottie-react` | `*` |
| `lottie-react-native` | `*` |
| `react` | `*` |
| `react-native` | `*` |
| `react-native-device-info` | `*` |
| `react-native-fast-confetti` | `*` |
| `react-native-fs` | `*` |
| `react-native-health-connect` | `*` |
| `react-native-image-picker` | `*` |
| `react-native-keyboard-controller` | `*` |
| `react-native-linear-gradient` | `*` |
| `react-native-picker-select` | `*` |
| `react-native-reanimated` | `>=4.0.0` |
| `react-native-safe-area-context` | `*` |
| `react-native-svg` | `*` |
| `react-native-vision-camera` | `*` |
| `react-native-webview` | `*` |

### Configure permissions

Several peers need usage descriptions in `Info.plist` (iOS) and permissions in `AndroidManifest.xml` (Android). Follow each package's own setup guide, in particular for the cameras (`expo-camera`, `react-native-vision-camera`), the photo pickers (`expo-image-picker`, `react-native-image-picker`), health data (`@kingstinct/react-native-healthkit`, `react-native-health-connect`) and Face ID (`expo-local-authentication`).

#### Example `Info.plist` entries

```xml
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses your camera to photograph meals and scan barcodes.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) lets you share meal photos from your library.</string>
<key>NSFaceIDUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to unlock the app with Face ID.</string>
```

In an Expo app, add the `expo-local-authentication` config plugin instead of editing `Info.plist` by hand. It writes `NSFaceIDUsageDescription`:

```json
[
  "expo-local-authentication",
  {
    "faceIDPermission": "Allow $(PRODUCT_NAME) to unlock the app with Face ID."
  }
]
```

#### Example `AndroidManifest.xml` entries

```xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
```
