@sirdata/react-native-cmp
v2.0.2
Published
SirData CMP React Native SDK — IAB TCF v2.2, GPP and CCPA/USP consent management
Readme
@sirdata/react-native-cmp
React Native SDK for the SirData Consent Management Platform (IAB TCF v2.2, GPP, CCPA/USP). Thin JavaScript bridge over the native SirData CMP SDKs — all IAB signals are written natively to SharedPreferences / NSUserDefaults, so ad and analytics SDKs embedded in your app read consent automatically.
import SirDataCMP from '@sirdata/react-native-cmp';
await SirDataCMP.initialize({ partnerId: 1020, configId: 'hmDnl' });
if (await SirDataCMP.shouldCollectConsent()) await SirDataCMP.showConsentUI();
// settings screen ("Manage my choices"): await SirDataCMP.showConsentUI();
const tcString = await SirDataCMP.getTcString();What's new in 2.0.2
- A settings entry lets the user withdraw a stored choice. Until now,
showConsentUI()reopened the banner as on a first visit, where "Continue without accepting" keeps an earlier "Accept all" recorded. It now opens as the web CMP does: in the workflow the display decision selects when the consent UI is due, which is whatstartConsent()needs, and otherwise in the native SDKs' reopen mode, with a close cross at the top and a "Reject all" button whatever the refusal option your configuration sets. Your settings entry needs no change.showConsentUI({ reopen: true })always opens the reopen mode. Upgrade withnpm install @sirdata/[email protected], then rebuild the app on both platforms: the module's native code changed.
What's new in 2.0.1
- iOS:
shouldCollectConsent(),acceptAll()andrejectAll()no longer terminate the app. In 2.0.0 these three calls crashed every iOS app: React Native runs module methods off the main thread, and the native SDK accepts these calls only on the main thread. Nothing else changes. Upgrade withnpm install @sirdata/[email protected], then rebuild the iOS app.
Installation
npm install @sirdata/react-native-cmp
cd ios && pod installWith Expo, in a development build or with EAS Build (Expo Go cannot load the module's native code):
npx expo install @sirdata/react-native-cmp
npx expo run:ios # runs prebuild and pod install; or: npx expo run:androidThe module is autolinked. Its pod depends on SirdataCMP ~> 2.0 from the
CocoaPods trunk, and its Android module on com.sirdata.cmp:android-sdk:2.0.0
from Maven Central: nothing to add to your Podfile or Gradle files.
Requirements: iOS 15.0+ (including your Podfile's platform :ios) and Android
API 23+ (the module inherits your app's minSdkVersion). Android builds need
JDK 17+ and Android Gradle Plugin 8.2+: the SDK's core is Java 21 bytecode,
built and dexed with AGP 8.2.2, and older plugins are not tested. Version
2.0.2 was verified end to end in an Expo SDK 57 app (React Native 0.86.3, New
Architecture), on an Android 17 emulator and on an iOS 26.5 simulator. The module
contains native code: with Expo it needs a development build, and it does not
work in Expo Go.
Native SDK setup, consent sharing with vendor SDKs and API reference: https://cmp.docs.sirdata.net/en/mobile-apps-native-sdk/mobile-sdk (French: https://cmp.docs.sirdata.net/applications-mobiles-sdk-natif/mobile-sdk).
