React Native SDK — Overview
The @truconsent/consent-notice-react-native package provides React Native components for consent banners and the Rights Center. It is designed for Expo-managed and bare React Native workflows. All API calls are made directly from the device.
How it works
Section titled “How it works”Two separate base URLs are involved:
| Purpose | URL | Used for |
|---|---|---|
| SDK runtime | https://trukit-dev.truconsent.io | TruConsentModal and NativeRightCenter at runtime |
| Management API | Your management API base URL | Fetching assetId and bannerId during setup |
Installation
Section titled “Installation”npx expo install @truconsent/consent-notice-react-nativeOr with npm/yarn:
npm install @truconsent/consent-notice-react-native# oryarn add @truconsent/consent-notice-react-nativeConfiguration (Expo)
Section titled “Configuration (Expo)”Store your SDK config in app.json under the extra key:
{ "expo": { "extra": { "truConsentApiKey": "your-consent-scope-key", "truConsentOrganizationId": "your-organization-id", "truConsentAssetId": "your-asset-id", "truConsentApiUrl": "https://trukit-dev.truconsent.io" } }}Read these values at runtime using Expo Constants:
import Constants from 'expo-constants';
const { truConsentApiKey, truConsentOrganizationId, truConsentAssetId, truConsentApiUrl,} = Constants.expoConfig?.extra ?? {};Setup steps
Section titled “Setup steps”-
Get API key and org ID — Generate credentials from the platform dashboard.
-
Fetch asset ID — Discover your
assetIdvia the Management API. -
Fetch collection point details — Discover your
bannerIdvia the Management API. -
Integrate consent banner — Mount
TruConsentModalwith Android/iOS platform setup. -
Integrate Rights Center — Mount
NativeRightCenterto handle DPDPA data subject rights.