Skip to main content

Getting started

The Fundamentals section of this documentation provides a tour of the most important aspects of ROOK SDK. It covers everything you need to know to integrate us into your application.

Minimum requirements

  • react-native >= 0.70

iOS

  • ios >= 13.0
  • XCode >= 14.2

Android

  • android >= 26.0
  • targeSDK >= 34.0
  • kotlin >= 1.8.10

Installation

npm i react-native-rook-sdk

If you're on a Mac and developing for iOS, you need to install the pods (via Cocoapods) to complete the linking.

  npx pod-install

Configure Apple Health and Health connect

Apple Health (iOS)

We need to add Apple Health Kit Framework to our project in order to that please:

  • Open your project in Xcode.
  • Click on your project file in the Project Navigator.
  • Select your target and then click on the "Build Phases" tab.
  • Click on the "+" button under the "Link Binary With Libraries" section and select "HealthKit.framework" from the list.
  • Select your target and then click on the "Signing Capabilities" tab.
  • Click on "Add Capability" and search for "HealthKit"

Additionally add the following to the info.plist

<key>NSHealthShareUsageDescription</key>
<string>This app requires access to your health and fitness data in order to track your workouts and activity levels.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>This app requires permission to write healt data to HealthKit.</string>

Health Connect (Android)

We need to configure the Android project. Open the Android project in Android Studio. To access the Health connection records, we need to modify the AndroidManifest.xml file. Add an intent filter inside your activity tag to open the Health Connect app. Your AndroidManifest.xml file should look like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

...

<application
...>
<activity
...>
<intent-filter>
...
</intent-filter>

<!-- For supported versions through Android 13, create an activity to show the rationale
of Health Connect permissions once users click the privacy policy link. -->
<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent-filter>
</activity>

<!-- For versions starting Android 14, create an activity alias to show the rationale
of Health Connect permissions once users click the privacy policy link. -->
<activity-alias
android:name="ViewPermissionUsageActivity"
android:exported="true"
android:permission="android.permission.START_VIEW_PERMISSION_USAGE"
android:targetActivity=".MainActivity">

<intent-filter>
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE" />
<category android:name="android.intent.category.HEALTH_PERMISSIONS" />
</intent-filter>
</activity-alias>
</application>
</manifest>

Included permissions

info

This SDK will use the following permissions, there is no need to declare them in your manifest as the rook-sdk already declares them in its own manifest.


<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<uses-permission android:name="android.permission.health.READ_SLEEP"/>
<uses-permission android:name="android.permission.health.READ_STEPS"/>
<uses-permission android:name="android.permission.health.READ_DISTANCE"/>
<uses-permission android:name="android.permission.health.READ_FLOORS_CLIMBED"/>
<uses-permission android:name="android.permission.health.READ_ELEVATION_GAINED"/>
<uses-permission android:name="android.permission.health.READ_OXYGEN_SATURATION"/>
<uses-permission android:name="android.permission.health.READ_VO2_MAX"/>
<uses-permission android:name="android.permission.health.READ_TOTAL_CALORIES_BURNED"/>
<uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED"/>
<uses-permission android:name="android.permission.health.READ_HEART_RATE"/>
<uses-permission android:name="android.permission.health.READ_RESTING_HEART_RATE"/>
<uses-permission android:name="android.permission.health.READ_HEART_RATE_VARIABILITY"/>
<uses-permission android:name="android.permission.health.READ_EXERCISE"/>
<uses-permission android:name="android.permission.health.READ_SPEED"/>
<uses-permission android:name="android.permission.health.READ_WEIGHT"/>
<uses-permission android:name="android.permission.health.READ_HEIGHT"/>
<uses-permission android:name="android.permission.health.READ_BLOOD_GLUCOSE"/>
<uses-permission android:name="android.permission.health.READ_BLOOD_PRESSURE"/>
<uses-permission android:name="android.permission.health.READ_HYDRATION"/>
<uses-permission android:name="android.permission.health.READ_BODY_TEMPERATURE"/>
<uses-permission android:name="android.permission.health.READ_RESPIRATORY_RATE"/>
<uses-permission android:name="android.permission.health.READ_NUTRITION"/>
<uses-permission android:name="android.permission.health.READ_MENSTRUATION"/>
<uses-permission android:name="android.permission.health.READ_POWER"/>

Google may require you to provide an explanation about the FOREGROUND_SERVICE and FOREGROUND_SERVICE_HEALTH permissions. These permissions are used by our Automatic Sync and Background Steps features to extract health data and upload it to ROOK servers. We recommend asking users for permission before enabling these features. Google may also require a video proof of a screen where a user can turn these features on or off.

Request data access

When you are developing with the Health Connect SDK data access is unrestricted. In order to have data access when your app is launched to the PlayStore you MUST complete the Developer Declaration Form, more information Here.

When you are asked about what data types is your app using please add the following data types as READ access:

  • ActiveCaloriesBurnedRecord
  • BloodGlucoseRecord
  • BloodPressureRecord
  • BodyTemperatureRecord
  • DistanceRecord
  • ElevationGainedRecord
  • ExerciseSessionRecord
  • FloorsClimbedRecord
  • HeartRateRecord
  • HeartRateVariabilityRmssdRecord
  • HeightRecord
  • HydrationRecord
  • MenstruationPeriodRecord
  • NutritionRecord
  • OxygenSaturationRecord
  • PowerRecord
  • RespiratoryRateRecord
  • RestingHeartRateRecord
  • SleepSessionRecord
  • SpeedRecord
  • StepsCadenceRecord
  • StepsRecord
  • TotalCaloriesBurnedRecord
  • Vo2MaxRecord
  • WeightRecord

Obfuscation

If you are using obfuscation consider the following:

In your proguard-rules.pro add the following rule:

-keep class com.google.crypto.** { *; }

In your gradle.properties (Project level) add the following to disable R8 full mode:

android.enableR8.fullMode=false

If you want to enable full mode add the following rules to proguard-rules.pro:

# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
# Crypto
-keep class com.google.crypto.** { *; }

Wrapping your app in RookSyncGate

Now, we need to wrap the whole app in RookSyncGate in order to add your credentials that are generated by the Rook Portal. Usually you'd do this in your entry file, such as index.js or App.js:

import * as React from "react";
import { RookSyncGate } from "react-native-rook-sdk";

export default function App() {
return (
<RookSyncGate
environment="sandbox"
clientUUID="YOUR-CREDENTIALS"
password="YOUR-CREDENTIALS"
enableLogs={true | false | undefined}
enableBackgroundSync={true | false}
>
<YOUR-COMPONENTS />
</RookSyncGate>
);
}

The value of enableLogs will display or not local logs in the console for certain SDK operations, We recommend you to ask your users if they want to enable the automatic sync, then save their preference in local storage and set enableBackgroundSync conditionally.