Expo installation

This package cannot be used in the “Expo Go” app because it requires custom native code.
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. First install the package with yarn, npm or npx expo install.
yarn install react-native-spike-sdk
After installing this npm package, add the config plugin to the plugins array of your app.json or app.config.js:
{
  "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” 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:
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 in order 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
  • Manual: Visit Apple developer portal and enable the HealthKit capability for your bundle identifier before building for production. This can also be done via Xcode.