Skip to main content
Supported on: iOS SDK 1.0.61+ · Android SDK 1.0.33+ · React Native SDK 1.0.4+
This guide walks you through configuring the AppDNA SDK, identifying users, and tracking your first event in a React Native application.

1. Configure the SDK

Initialize AppDNA as early as possible in your app lifecycle, typically in your app entry point (index.js, App.tsx, or similar) before rendering the root component:
import { AppDNA } from '@appdna/react-native-sdk';

async function bootstrap(): Promise<void> {
  await AppDNA.configure({
    apiKey: 'adn_live_xxx',
    env: 'production',
    options: { logLevel: 'debug' },
  });
}

bootstrap();
If you don’t have your own Firebase: The AppDNA SDK manages a separate named Firebase instance internally — no firebase package install required.If you already use Firebase in your app (via @react-native-firebase/app or similar): the SDK automatically initializes its own named Firebase instance from GoogleService-Info-AppDNA.plist (iOS) and google-services-appdna.json (Android). Your existing Firebase setup is not affected.
Call AppDNA.configure(...) exactly once before using any other SDK methods. Calling it multiple times will result in undefined behavior.

Configuration Options

The AppDNAOptions interface lets you customize SDK behavior:
ParameterTypeDefaultDescription
flushIntervalnumber?30Seconds between automatic event flushes
batchSizenumber?20Number of events to batch before flushing
configTTLnumber?3600Seconds before cached config is considered stale
logLevelAppDNALogLevel?'warning'Verbosity of SDK console logs
billingProviderAppDNABillingProvider?'storeKit2'Billing integration to use

Environment

The AppDNAEnvironment type controls which backend environment the SDK targets:
ValueDescription
'production'Production API and configuration
'staging'Staging API for testing

Log Level

The AppDNALogLevel type controls console log verbosity:
ValueDescription
'none'No logging
'error'Errors only
'warning'Errors and warnings
'info'Errors, warnings, and info
'debug'All messages including debug
Use 'debug' during development to see all SDK activity. Switch to 'warning' or 'none' for production builds.

Billing Provider

The AppDNABillingProvider type specifies which billing system to use:
ValueDescription
'storeKit2'Native StoreKit 2 on iOS, Play Billing on Android (default)
'revenueCat'RevenueCat integration
'adapty'Adapty integration (pass API key via adaptyApiKey option)
'none'Disable the billing module
On Android the SDK uses Google Play Billing under the StoreKit2 alias. RevenueCat is supported across both platforms when the native bridges are configured.

2. Wait for Ready State

The SDK fetches remote configuration asynchronously. Use onReady to know when the SDK is fully initialized:
await AppDNA.onReady(() => {
  console.log('SDK ready -- remote config loaded');
});
onReady() accepts a callback that runs once the remote configuration has been fetched and applied.

3. Identify Users

Once a user signs in, call identify to associate events with their user ID:
await AppDNA.identify('user-123', {
  plan: 'premium',
  signup_date: '2025-01-15',
});
Traits are merged with any previously set traits. You do not need to pass all traits on every call — only the ones that have changed.

4. Track Events

Track user actions with track:
await AppDNA.track('workout_completed', {
  duration: 45,
  type: 'strength',
});
Events are batched and flushed automatically based on your flushInterval and batchSize settings.

5. Flush Events Manually

Force an immediate flush of all queued events:
await AppDNA.flush();
This is useful before the app enters the background or when you need to ensure events are sent immediately. Control whether the SDK collects and sends analytics data:
await AppDNA.setConsent({ analytics: true });
When analytics is set to false, events are silently dropped and not queued. No data is sent to AppDNA servers until consent is granted.

7. Change Log Level at Runtime

Adjust the log level without reconfiguring the SDK:
AppDNA.setLogLevel('debug');
Valid levels: 'none', 'error', 'warning', 'info', 'debug'.

8. Remote Config and Feature Flags

Retrieve server-side configuration values:
const welcomeMessage = await AppDNA.getRemoteConfig('welcome_message');
Check whether a feature flag is enabled:
const darkModeEnabled = await AppDNA.isFeatureEnabled('dark_mode');

9. Experiments

Get the variant assigned to a user for an experiment:
const variant = await AppDNA.getExperimentVariant('paywall_test');
Check if the user is in a specific variant:
const isInVariantB = await AppDNA.isInVariant('paywall_test', 'b');
Inspect all experiment exposures collected during the current session:
const exposures = await AppDNA.experiments.getExposures();
for (const exposure of exposures) {
  console.log(`${exposure.experimentId}${exposure.variant}`);
}

10. Session Data

Store cross-module session data that can be used in template interpolation across onboarding flows, paywalls, and in-app messages:
// Store session data
await AppDNA.setSessionData({ key: 'selected_plan', value: 'premium' });
await AppDNA.setSessionData({ key: 'referral_code', value: 'FRIEND2026' });

// Retrieve session data
const plan = await AppDNA.getSessionData({ key: 'selected_plan' }); // "premium"

// Clear all session data
await AppDNA.clearSessionData();
Session data values are accessible in Console-configured content using template syntax: {{session.selected_plan}}. See the Rich Media guide for the full template namespace ({{user.*}}, {{session.*}}, {{device.*}}, {{config.*}}).

11. Entitlements

Check whether the user has any active subscription (StoreKit, Play Billing, RevenueCat, or web entitlement):
const isSubscribed = await AppDNA.billing.hasActiveSubscription();
Subscribe to live entitlement updates so your UI reflects renewals, cancellations, and restored purchases without polling:
const unsubscribe = AppDNA.billing.onEntitlementsChanged((entitlements) => {
  const active = entitlements.filter((e) => e.status === 'active');
  console.log(`Active entitlements: ${active.length}`);
});
See the Billing guide for the full purchase and restore flow.

12. Web Entitlement

Retrieve the current web entitlement (subscriptions granted outside the app store, e.g. via Stripe):
const ent = await AppDNA.getWebEntitlement();
Listen for web entitlement changes in real time:
const unsubscribe = AppDNA.onWebEntitlementChanged((ent) => {
  console.log('Web entitlement changed:', ent);
});
Check for a deferred deep link that brought the user to your app on first launch:
const link = await AppDNA.checkDeferredDeepLink();
if (link) {
  // Navigate to the linked content
}

14. Get SDK Version

Print the underlying native SDK version (useful for support tickets):
const version = await AppDNA.getSdkVersion();
console.log(`Native SDK version: ${version}`);

15. Reset on Logout

When a user signs out, call reset to clear the user identity and flush any remaining events:
await AppDNA.reset();
This clears the identified user, generates a new anonymous ID, and flushes queued events.

16. Shutdown

When the app is terminating, shut down the SDK to ensure all events are flushed and resources are released:
await AppDNA.shutdown();
On Android this releases native resources. On iOS this is a no-op because the SDK shuts down automatically when the process exits.
You now have the SDK configured with user identification, event tracking, remote config, experiments, entitlements, and deep links working. Continue to the module-specific guides for Push Notifications, Billing, Onboarding, and Paywalls.