# React Native

The React Native wrapper for the native SDKs supports all functionalities of the native SDKs unless stated differently.

{% hint style="info" %}
Starting from version 5.2.0, the Thryve React Native SDK, supports integration via the [new Samsung Health Data for Android](https://developer.samsung.com/health/data/overview.html) exclusively. Read more on the [Thryve Samsung Health module](/thryve-data-sources/samsung-health.md)
{% endhint %}

## Configuration of projects

To integrate the Thryve React Native SDK into a bare React Native, follow the steps below for installing the packages. If you are using React Native Expo, please refer to the [dedicated page](/integrate-your-mobile-app/setup-thryve-sdk/react-native/react-native-expo.md).

### Install packages

Download the `.tgz` package files provided by Thryve and place them in a directory inside your project (e.g. `./packages/`). Then install the core SDK and the individual module packages for the integrations your app uses.

```sh
# Install the core SDK
npm install ./packages/thryve-react-native-sdk-<version>.tgz

# Install only the modules you need
npm install ./packages/thryve-react-native-hconnect-module-<version>.tgz   # Health Connect (Android only)
npm install ./packages/thryve-react-native-samsung-health-module-<version>.tgz    # Samsung Health (Android only)
npm install ./packages/thryve-react-native-apple-health-module-<version>.tgz # Apple HealthKit (iOS only)
npm install ./packages/thryve-react-native-shenai-module-<version>.tgz     # ShenAI (Android & iOS)
```

Replace `<version>` with the version number of the package files you received (e.g. `5.2.0`). After installation your `package.json` dependencies will reference the local `.tgz` paths:

```json
"dependencies": {
  "@thryve/react-native-sdk": "./packages/thryve-react-native-sdk-5.2.0.tgz",
  "@thryve/react-native-hconnect-module": "./packages/thryve-react-native-hconnect-module-5.2.0.tgz",
  "@thryve/react-native-samsung-health-module": "./packages/thryve-react-native-samsung-health-module-5.2.0.tgz",
  "@thryve/react-native-apple-health-module": "./packages/thryve-react-native-apple-health-module-5.2.0.tgz",
  "@thryve/react-native-shenai-module": "./packages/thryve-react-native-shenai-module-5.2.0.tgz"
}
```

### Setup Android configuration

#### Configure Nexus Maven repository (`android/settings.gradle`)

Add the Thryve Nexus repository so Gradle can resolve the native Android dependencies. Credentials are read from `android/local.properties` first, falling back to environment variables — keep them out of source control.

```groovy
// android/settings.gradle
def localProps = new Properties()
def localPropsFile = new File(settingsDir, 'local.properties')
if (localPropsFile.exists()) { localPropsFile.withInputStream { localProps.load(it) } }
def resolvedUser = localProps['THRYVE_NEXUS_USERNAME'] ?: System.getenv('THRYVE_NEXUS_USERNAME') ?: ""
def resolvedPass = localProps['THRYVE_NEXUS_PASSWORD'] ?: System.getenv('THRYVE_NEXUS_PASSWORD') ?: ""

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://nexus.external.thryve.de/repository/releases/"
            credentials {
                username = resolvedUser
                password = resolvedPass
            }
            content {
                includeGroupByRegex "com\\.thryve.*"
            }
        }
    }
}
```

Add your credentials to `android/local.properties` (this file should be in `.gitignore`):

```
THRYVE_NEXUS_USERNAME=YOUR_SDK_CREDENTIAL_USER
THRYVE_NEXUS_PASSWORD=YOUR_SDK_CREDENTIAL_PASSWORD
```

#### Add Thryve SDK dependencies (`android/app/build.gradle`)

Add the required runtime dependencies:

```groovy
dependencies {
    implementation("androidx.security:security-crypto:1.1.0-alpha06")
    implementation("io.reactivex.rxjava2:rxjava:2.2.21")
    implementation("io.reactivex.rxjava2:rxandroid:2.1.1")
    // ... your other dependencies
}
```

#### Define Android SDK versions (`android/build.gradle`)

Ensure your project-level `build.gradle` targets the required SDK versions:

```groovy
ext {
    minSdkVersion = 26
    compileSdkVersion = 36
    targetSdkVersion = 36
    buildToolsVersion = "36.0.0"
}
```

#### Configure project when using Health Connect

{% hint style="info" %}
For more details exceeding below explanations, please refer to the [sample code](https://git.thryve.de/thryve/react-native/-/tree/main) demonstrating the SDK configuration.
{% endhint %}

**Android Manifest**

When using Health Connect you need to declare the that your app will query HealthConnect and display the permission rational as well as declare the data types you intend to use. Do this in your `android/app/src/main/AndroidManifest.xml` .

{% hint style="warning" %}
Declare only the data type your app actually reads and needs — extensive permission requests require justification during Google Play Store review. Every data type you pass to `start()` must have its corresponding permission declared here, otherwise Health Connect will reject the call at runtime (error 90005).
{% endhint %}

Import `HEALTH_CONNECT_PERMISSIONS` from `@thryve/react-native-sdk/permissions` as a reference for all available permission strings.

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

    <uses-permission android:name="android.permission.health.READ_HEART_RATE"/>
    <uses-permission android:name="android.permission.health.READ_STEPS"/>
    <uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED"/>
    <uses-permission android:name="android.permission.health.READ_SLEEP"/>
    <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_WEIGHT"/>
    <uses-permission android:name="android.permission.health.READ_HEIGHT"/>
    <uses-permission android:name="android.permission.health.READ_OXYGEN_SATURATION"/>
    <uses-permission android:name="android.permission.health.READ_BODY_TEMPERATURE"/>
    <!-- Add further Health Connect permissions your app needs -->

    <uses-sdk tools:overrideLibrary="androidx.health.connect.client"/>

    <queries>
        <package android:name="com.google.android.apps.healthdata"/>
    </queries>

    <application ...>
        <!-- Health Connect rationale activity — required for health-connect module -->
        <activity
            android:name=".PermissionsActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE"/>
            </intent-filter>
            <meta-data
                android:name="health_permissions"
                android:resource="@array/health_permissions"/>
        </activity>
        <activity-alias
            android:name="AndroidURationaleActivity"
            android:exported="true"
            android:targetActivity=".PermissionsActivity"
            android:permission="android.permission.START_VIEW_PERMISSION_USAGE">
            <intent-filter>
                <action android:name="android.intent.action.VIEW_PERMISSION_USAGE"/>
                <category android:name="android.intent.category.HEALTH_PERMISSIONS"/>
            </intent-filter>
        </activity-alias>
        <!-- ... rest of application -->
    </application>
</manifest>

```

**Health Permission resource**

List the same Health Connect permissions that you declared in the manifest in `android/app/src/main/res/values/health_permissions.xml` .

```xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <array name="health_permissions">
    <item>android.permission.health.READ_HEART_RATE</item>
    <item>android.permission.health.READ_STEPS</item>
    <item>android.permission.health.READ_ACTIVE_CALORIES_BURNED</item>
    <item>android.permission.health.READ_SLEEP</item>
    <item>android.permission.health.READ_BLOOD_GLUCOSE</item>
    <item>android.permission.health.READ_BLOOD_PRESSURE</item>
    <item>android.permission.health.READ_WEIGHT</item>
    <item>android.permission.health.READ_HEIGHT</item>
    <item>android.permission.health.READ_OXYGEN_SATURATION</item>
    <item>android.permission.health.READ_BODY_TEMPERATURE</item>
    <!-- Mirror the permissions declared in AndroidManifest.xml -->
  </array>
</resources>
```

**Permission activity**

Additionally you need to create this file in your app's package directory (`android/app/src/main/java/<your.package>/PermissionsActivity.kt` ):

```kotlin
package your.app.package

import androidx.activity.ComponentActivity

class PermissionsActivity : ComponentActivity()
```

{% hint style="info" %}
Replace `your.app.package` in above path with your actual application package name (e.g. `com.example.myapp`).
{% endhint %}

#### Configure project when using Samsung Health

When allowing users to connect to Samsung Health ensure to declare queries in your `android/app/src/main/AndroidManifest.xml` .

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools">
          
    <queries>
        <!-- Samsung Health queries — include only if using samsung-health module -->
        <package android:name="com.samsung.health"/>
        <package android:name="com.sec.android.app.shealth"/>
        
        <!-- ... rest of queries, see section above for Health Connect -->
    </queries>
    
    <!-- ... rest of manifest -->
</manifest>
```

### Setup iOS configuration

#### Configure the Podfile&#x20;

Add the Thryve CocoaPods source in your `ios/Podfile` and include only the subspecs your app uses:

```ruby
source 'https://git.thryve.de/thryve/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'

# ... rest of Podfile setup ...

target 'YourAppTarget' do
  config = use_native_modules!

  # Include only the subspecs your app uses: 'AppleHealth', 'ShenAI'
  pod 'RNThryveSDKModule', :path => '../node_modules/@thryve/react-native-sdk',
    :subspecs => ['AppleHealth', 'ShenAI']

  use_react_native!(
    :path => config[:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
end
```

After you have added the configuration, ensure to run:

```sh
cd ios && pod install && cd ..
```

#### Configure the Info.plist&#x20;

Add the required usage descriptions in `ios/<YourApp>/Info.plist` :

<pre class="language-xml"><code class="lang-xml">&#x3C;!-- Required for Apple Health only -->
<strong>&#x3C;key>NSHealthShareUsageDescription&#x3C;/key>
</strong>&#x3C;string>This app needs permission to share your health data&#x3C;/string>
&#x3C;key>NSHealthUpdateUsageDescription&#x3C;/key>
&#x3C;string>This app needs permission to update your health data&#x3C;/string>
&#x3C;!-- Required for ShenAI only -->
&#x3C;key>NSCameraUsageDescription&#x3C;/key>
&#x3C;string>Camera is required for ShenAI facial health measurements&#x3C;/string>
&#x3C;!-- Required for Apple Health background delivery -->
&#x3C;key>UIBackgroundModes&#x3C;/key>
&#x3C;array>
  &#x3C;string>fetch&#x3C;/string>
&#x3C;/array>
</code></pre>

#### Configure the required entitlements

When using Apple Health add the following HealthKit entitlements in your `ios/<YourApp>/<YourApp>.entitlements` .

```xml
<key>com.apple.developer.healthkit</key>
<true/>
<key>com.apple.developer.healthkit.background-delivery</key>
<true/>
```

### Common issues

#### iOS build error: `Typedef redefinition with different types` in `RCT-Folly/folly/portability/Time.h`

Some users have reported the following error when building for iOS:

```
RCT-Folly/folly/portability/Time.h:52:17: Typedef redefinition with different types
('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
```

**Option 1:** Add the following `sed` command to your `post_install` block in `ios/Podfile`:

```ruby
post_install do |installer|
  # ...existing post_install steps...
  sed -i -e $'s/__IPHONE_10_0/__IPHONE_13_0/' Pods/RCT-Folly/folly/portability/Time.h
end
```

**Option 2:** If the above does not resolve the issue, open `ios/Pods/RCT-Folly/folly/portability/Time.h` and comment out the offending line:

```c
// typedef uint8_t clockid_t;
```

## Migrating to React Native SDK 5.2.0

### Breaking changes

#### Samsung Health data types replaced

The entire `ThryveSamsungHealthDataType` enum has been replaced to align with the new Samsung Health data model. All previous values are removed with no backwards-compatible aliases.

**You must update every reference** in your app to use the new values listed in the [ThryveSamsungHealthDataType reference](https://docs.thryve.health/thryve-data-sources/samsung-health#step-2-use-the-new-configuration-model).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.thryve.health/integrate-your-mobile-app/setup-thryve-sdk/react-native.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
