React Native

circle-info

The Hackle React Native SDK supports React 16.8 and above, and React Native 0.64.1 and above.

The React Native SDK is built on top of the Android SDK and iOS SDK. The following OS versions are supported.

  • Android API 16 (4.1 Jelly Bean) and above

  • iOS 13 and above

circle-info

Starting from Hackle React Native SDK version 3.31.0, the minimum supported iOS version has been raised to iOS 13.

For versions below Hackle React Native SDK 3.31.0, the minimum supported version is iOS 10.

Add Dependency

circle-exclamation

arrow-up-right

npm install --save @hackler/react-native-sdk

iOS

cd ios
pod install

Adding Dependency with Expo

circle-info

Expo is supported in React Native SDK version 3.17.0 and above.

triangle-exclamation

When using Expo, you do not need to run link or pod install.

Android Configuration

circle-exclamation
circle-exclamation

Add the following code to your Application class under the onCreate function.

SDK Initialization

To use the SDK, you must pass the SDK Key to createInstance() to create a HackleReactNativeSDKClient and pass it to the HackleProvider that wraps your React application.

At initialization, the SDK fetches necessary data from the Hackle server and stores it. This typically takes only a few milliseconds. Rendering begins immediately after synchronization is complete.

Injecting User at Initialization

circle-info

This feature is supported in React Native SDK version 3.31.0 and above.

You can initialize the SDK with user information included.

  • If no user information is provided, the user information stored in local storage is used.

  • If user information is provided, the user information stored in local storage is not used.

  • If no user is injected and there is no user information in local storage, a user with the Hackle Device ID as the device id is used.

circle-info

You can freely update user information after SDK initialization using the user information setter functions.

circle-exclamation

SDK Initialization Config

You can initialize the SDK with configuration options.

Option
Description
Default
Supported Version

exposureEventDedupIntervalMillis

Removes duplicate exposure events for the same A/B Test or Feature Flag distribution result triggered by the same user consecutively. Minimum: 1000 (1 second) Maximum: 3600000 (1 hour)

-1 (no dedup)

3.3.1+

debug

Prints logs for all features to the console and sends events immediately.

false

3.4.1+

pollingIntervalMillis

Periodically updates the configuration set in the Dashboard. Minimum: 60000 (60 seconds)

-1 (no periodic update)

3.6.0+

automaticAppLifecycleTracking

Whether to enable automatic app start/end tracking

true

3.30.0+

automaticScreenTracking

Whether to enable automatic screen tracking

true

3.30.0+

sessionPolicy

Configures session persistence and expiration conditions.

persistCondition: alwaysNewSession,

timeoutMillis: 1800000 (30 min)

3.32.0+

optOutTracking

Whether opt-out is enabled. When enabled, all event sending is stopped.

false

3.32.0+

sessionTimeoutMillis (deprecated)

Sets the session expiration time. Please use sessionPolicy instead.

1800000 (30 min)

3.11.0+

Session Policy Configuration

You can configure session persistence and expiration conditions using the session policy.

Refreshing Dashboard Configuration

You can explicitly refresh the Dashboard configuration.

circle-exclamation

Last updated