Step 1: Install and initialize
Add the Digia Engage SDK and the CleverTap plugin to your React Native, Android, iOS and Flutter app, then initialize both in the right order.
Minimum Supported Versions
- React Native
- Android
- iOS (Swift)
- Flutter
- Environment: React Native
0.83+, React19.2+ - Digia packages:
@digia-engage/core,@digia-engage/clevertap - CleverTap SDK:
clevertap-react-native
- Environment:
minSdk 25 - Digia packages:
tech.digia:engage,tech.digia:engage-clevertap - CleverTap SDK:
com.clevertap.android:clevertap-android-sdk
- Environment: iOS
16+ - Digia packages:
DigiaEngage,DigiaEngageCleverTap - CleverTap SDK:
CleverTapSDK
- Environment: Dart
3.3+, Flutter3.29+ - Digia packages:
digia_engage,digia_engage_clevertap - CleverTap SDK:
clevertap_plugin
Install
Note: We assume the core CleverTap SDK is already installed and initialized as part of your standard app setup (see Before you start). The snippets below only cover adding the Digia plugin packages.
- React Native
- Android
- iOS (Swift)
- Flutter
Install the Digia packages:
npm install @digia-engage/core@3.6.0 @digia-engage/clevertap@3.0.0
Add dependencies in app build.gradle.kts (use the latest versions from Maven Central):
dependencies {
implementation("tech.digia:engage:3.6.0")
implementation("tech.digia:engage-clevertap:3.0.1")
}
Sync the project (Gradle sync).
Add packages using Xcode → File → Add Package Dependencies and choose Up to Next Major Version — or in Package.swift, use the latest versions from Swift Package Index:
dependencies: [
.package(url: "https://github.com/Digia-Technology-Private-Limited/digia_engage_iOS.git", from: "4.6.0"),
.package(url: "https://github.com/Digia-Technology-Private-Limited/digia_engage_clevertap_iOS.git", from: "2.0.1"),
],
Then add these products to your app target dependencies:
DigiaEngageDigiaEngageCleverTap
Add the Digia packages using the flutter pub add command:
flutter pub add digia_engage:2.4.1 digia_engage_clevertap:2.0.0
Initialize Digia with CleverTap
Register the Digia CleverTap plugin as soon as CleverTap starts, then initialize Digia. The plugin holds any campaign CleverTap sends until Digia is ready, so registering early means no campaign is missed. A campaign CleverTap sends before the plugin is registered can be lost.
- React Native
- Android
- iOS (Swift)
- Flutter
JS setup
import { useEffect } from 'react';
import CleverTap from 'clevertap-react-native';
import { Digia } from '@digia-engage/core';
import { DigiaCleverTapPlugin, createCleverTapClient } from '@digia-engage/clevertap';
export function RootApp() {
useEffect(() => {
(async () => {
// 1. CleverTap SDK — must be initialized as a prerequisite.
// 2. Register the Digia CleverTap plugin right away, so no campaign is missed.
await Digia.register(
new DigiaCleverTapPlugin({
cleverTap: createCleverTapClient(CleverTap),
})
);
// 3. Start Digia. Waiting for it is optional (see "Wait for Digia, or not" below).
await Digia.initialize({
apiKey: 'YOUR_ACCESS_KEY',
});
// 4. Wire screen tracking to your navigation library.
// Call Digia.setCurrentScreen(routeName) on every navigation change so
// screen-triggered campaigns fire on the correct screen.
})().catch(console.error);
}, []);
return <AppNavigator />;
}
Android native setup
Important: Even in a React Native app, the CleverTap SDK requires Activity lifecycle registration on the Android side. Without it, all In-App campaigns (including App Launch triggers), push notification click callbacks from the killed state, and session tracking will not work. See the CleverTap React Native Android integration guide.
- Extending
CleverTapApplication— registration is handled automatically. No extra call needed.- Not extending
CleverTapApplication— callActivityLifecycleCallback.register(this)manually inMainApplication.onCreate(), beforesuper.onCreate():
- Kotlin
- Java
import com.clevertap.android.sdk.ActivityLifecycleCallback
import com.clevertap.react.CleverTapRnAPI
class MainApplication : ReactApplication {
override fun onCreate() {
ActivityLifecycleCallback.register(this) // must be before super.onCreate()
super.onCreate()
CleverTapRnAPI.initReactNativeIntegration(this) // must be after super.onCreate()
// ...
}
}
import com.clevertap.android.sdk.ActivityLifecycleCallback;
import com.clevertap.react.CleverTapRnAPI;
public class MainApplication implements ReactApplication {
@Override
public void onCreate() {
ActivityLifecycleCallback.register(this); // must be before super.onCreate()
super.onCreate();
CleverTapRnAPI.initReactNativeIntegration(this); // must be after super.onCreate()
// ...
}
}
Also required:
CleverTapRnAPI.initReactNativeIntegration(this)must be called aftersuper.onCreate(). Without it, push notification click callbacks will not fire when the app is in the killed state (ClevertapPushNotificationClickedevent will be lost).
iOS native setup
Important: Even in a React Native app,
CleverTap.autoIntegrate()must be called in your nativeAppDelegatebefore the React bridge initializes. Without it, CleverTap cannot intercept push notifications, deep links, or app launch events on iOS — meaning App Launch triggered campaigns, push notification handling, and In-App display will not work. See the CleverTap React Native iOS integration guide.
- Swift
- Objective-C
// AppDelegate.swift
import CleverTapSDK
import CleverTapReact
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
CleverTap.autoIntegrate()
CleverTapReactManager.sharedInstance()?.applicationDidLaunch(options: launchOptions)
// ...
return true
}
}
// AppDelegate.mm
#import <CleverTap-iOS-SDK/CleverTap.h>
#import <clevertap-react-native/CleverTapReactManager.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[CleverTap autoIntegrate];
[[CleverTapReactManager sharedInstance] applicationDidLaunchWithOptions:launchOptions];
// ...
return YES;
}
Important (Android — Activity Lifecycle Registration): The CleverTap SDK needs to observe Activity lifecycle events to correctly handle In-App campaigns (including App Launch triggers), push notification click callbacks from the killed state, and session tracking. How you register depends on your
Applicationclass setup:
- Extending
CleverTapApplication— registration is handled automatically by the superclass. No extra call needed.- Not extending
CleverTapApplication— you must callActivityLifecycleCallback.register(this)manually, beforesuper.onCreate(), as shown below.See CleverTap Android integration guide for full details.
import android.app.Application
import com.clevertap.android.sdk.ActivityLifecycleCallback
import com.digia.engage.Digia
import com.digia.engage.DigiaConfig
import com.digia.engage.clevertap.DigiaCleverTapPlugin
class MyApplication : Application() {
override fun onCreate() {
// Must be called before super.onCreate() — see note above.
ActivityLifecycleCallback.register(this)
super.onCreate()
// 2. Register the Digia CleverTap plugin right away, so no campaign is missed.
// Context is required to resolve the CleverTap default instance.
Digia.register(DigiaCleverTapPlugin(applicationContext))
// 3. Start Digia without blocking onCreate (see "Wait for Digia, or not" below).
Digia.initialize(applicationContext, DigiaConfig(apiKey = "YOUR_ACCESS_KEY"), callback = null)
}
}
import SwiftUI
import DigiaEngage
import DigiaEngageCleverTap
@main
struct MyApp: App {
init() {
// 1. CleverTap SDK — initialized as a prerequisite.
CleverTap.autoIntegrate()
// 2. Register the Digia CleverTap plugin right away, so no campaign is missed.
Digia.register(DigiaCleverTapPlugin())
// 3. Start Digia (see "Wait for Digia, or not" below).
Task {
try? await Digia.initialize(DigiaConfig(apiKey: "YOUR_ACCESS_KEY"))
}
}
var body: some Scene {
WindowGroup {
RootView()
}
}
}
import 'package:digia_engage/digia_engage.dart';
import 'package:digia_engage_clevertap/digia_engage_clevertap.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// 1. CleverTap SDK — initialized as a prerequisite.
// 2. Start Digia and register the CleverTap plugin on the next line, so no
// campaign is missed.
final digiaReady = Digia.initialize(DigiaConfig(apiKey: 'YOUR_ACCESS_KEY'));
Digia.register(DigiaCleverTapPlugin());
// 3. Optional: wait until campaigns have loaded (see "Wait for Digia, or not" below).
await digiaReady;
runApp(const MyApp());
}
Android native setup
Important: Even in a Flutter app, the CleverTap SDK requires Activity lifecycle registration on the Android side. Without it, In-App campaigns (including App Launch triggers), push notification click callbacks from the killed state, and session tracking will not work. See the CleverTap Flutter Android integration guide.
Register
ActivityLifecycleCallbackin yourApplicationclass, beforesuper.onCreate():
- Kotlin
- Java
import com.clevertap.android.sdk.ActivityLifecycleCallback
import io.flutter.app.FlutterApplication
class MyApplication : FlutterApplication() {
override fun onCreate() {
ActivityLifecycleCallback.register(this) // must be before super.onCreate()
super.onCreate()
}
}
import com.clevertap.android.sdk.ActivityLifecycleCallback;
import io.flutter.app.FlutterApplication;
public class MyApplication extends FlutterApplication {
@Override
public void onCreate() {
ActivityLifecycleCallback.register(this); // must be before super.onCreate()
super.onCreate();
}
}
iOS native setup
Important: Even in a Flutter app,
CleverTap.autoIntegrate()must be called in your nativeAppDelegatebefore the Flutter engine initializes. Without it, CleverTap cannot intercept push notifications, deep links, or App Launch events on iOS — meaning App Launch triggered campaigns and In-App display will not work. See the CleverTap Flutter iOS integration guide.
- Swift
- Objective-C
// AppDelegate.swift
import CleverTapSDK
import clevertap_plugin
@UIApplicationMain
class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
CleverTap.autoIntegrate()
CleverTapPlugin.sharedInstance()?.applicationDidLaunch(options: launchOptions)
// ...
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
// AppDelegate.m
#import <CleverTap-iOS-SDK/CleverTap.h>
#import <clevertap_plugin/CleverTapPlugin.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[CleverTap autoIntegrate];
[[CleverTapPlugin sharedInstance] applicationDidLaunchWithOptions:launchOptions];
// ...
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
Wait for Digia, or not
Digia.initialize returns once campaigns have loaded, or after 2 seconds, whichever comes first. You
choose whether your app waits for it:
- Wait when campaigns at app start matter most. Campaigns are ready before your first screen, but startup can take up to 2 seconds longer.
- Don't wait when startup speed matters most. Your app starts at once, and campaigns load in the background.
- React Native
- Android
- iOS (Swift)
- Flutter
// Wait
await Digia.initialize({ apiKey: 'YOUR_API_KEY' });
// Don't wait
Digia.initialize({ apiKey: 'YOUR_API_KEY' }).catch(console.error);
// Wait: call the suspending version from a coroutine, for example in your first Activity.
// It returns once campaigns are ready, or after 2 seconds.
lifecycleScope.launch {
Digia.initialize(applicationContext, DigiaConfig(apiKey = "YOUR_API_KEY"))
showHome()
}
// Don't wait: returns at once. The callback runs when Digia is ready.
Digia.initialize(applicationContext, DigiaConfig(apiKey = "YOUR_API_KEY")) { ready -> }
Never use runBlocking on the main thread to wait for Digia; it freezes your app.
// Wait: in an async context, before showing your first screen.
try await Digia.initialize(DigiaConfig(apiKey: "YOUR_API_KEY"))
// Don't wait
Task { try? await Digia.initialize(DigiaConfig(apiKey: "YOUR_API_KEY")) }
// Wait: before runApp.
await Digia.initialize(DigiaConfig(apiKey: 'YOUR_API_KEY'));
// Don't wait (import 'dart:async')
unawaited(Digia.initialize(DigiaConfig(apiKey: 'YOUR_API_KEY')));
Either way, campaigns CleverTap sends before Digia is ready aren't lost: the plugin holds them for up to 5 minutes and shows them once Digia is ready.
Optional settings
Pass these alongside your API key when you initialize. All four are optional: leave any of them out and the SDK uses its default.
- React Native
- Android
- iOS (Swift)
- Flutter
await Digia.initialize({
apiKey: 'YOUR_API_KEY',
logLevel: __DEV__ ? 'verbose' : 'error', // 'none' | 'error' | 'verbose'. Default: 'error'
fontFamily: 'Poppins', // a font your app bundles (see Font below)
themeMode: 'auto', // 'auto' | 'light' | 'dark'. Default: 'auto'
// actionHandlers: { ... } // see Campaign Actions
});
import com.digia.engage.DigiaConfig
import com.digia.engage.DigiaLogLevel
import com.digia.engage.DigiaThemeMode
val config = DigiaConfig(
apiKey = "YOUR_API_KEY",
logLevel = DigiaLogLevel.DEBUG, // NONE | ERROR | WARN | INFO | DEBUG. Leave out for the default
fontFamily = "Poppins", // a font in res/font (see Font below)
themeMode = DigiaThemeMode.AUTO, // AUTO | LIGHT | DARK. Default: AUTO
// actionHandlers = DigiaActionHandlers(...) // see Campaign Actions
)
// Pass `config` to Digia.initialize as shown above.
let config = DigiaConfig(
apiKey: "YOUR_API_KEY",
logLevel: .debug, // .none | .error | .warn | .info | .debug. Default: .auto
fontFamily: "Poppins", // a font your app bundles (see Font below)
themeMode: .auto // .auto | .light | .dark. Default: .auto
// actionHandlers: DigiaActionHandlers(...) // see Campaign Actions
)
// Pass `config` to Digia.initialize as shown above.
Keep the arguments in this order. Swift requires it.
final config = DigiaConfig(
apiKey: 'YOUR_API_KEY',
logLevel: DigiaLogLevel.debug, // none | error | warn | info | debug. Leave out for the default
fontFamily: 'Poppins', // a family from your pubspec.yaml (see Font below)
themeMode: DigiaThemeMode.auto, // auto | light | dark. Default: auto
// actionHandlers: DigiaActionHandlers(...) // see Campaign Actions
);
// Pass `config` to Digia.initialize as shown above.
Log level (logLevel)
Sets how much the SDK writes to your app's logs. Every line starts with [DIGIA (plugin lines
add the plugin's name, for example [DIGIA-CT]), so search your logs for DIGIA.
| Level | What it logs |
|---|---|
none | Nothing, not even errors. |
error | Only failures: a campaign was dropped, an action failed. |
warn | Errors, plus problems the SDK recovered from, such as a setting that fell back to its default. |
info | Warnings, plus milestones: SDK ready, campaigns loaded, a campaign triggered. |
debug | Everything, including why each campaign showed or didn't. Use this when debugging. |
verbose | The same as debug. It's the older name and still works. |
Default on Android, iOS and Flutter: if you leave logLevel out, the SDK uses debug in debug
builds and error in release builds, so you get full logs while developing without changing
anything. iOS treats simulator, development-signed and TestFlight builds as debug builds, and App
Store installs as release builds. Flutter treats anything not built in release mode as a debug
build. Set a level only to override this, for example debug in a QA build to look into a problem.
Take it out again before you ship.
React Native accepts only 'none', 'error' and 'verbose', and defaults to 'error' in every
build. Set 'verbose' while debugging: __DEV__ ? 'verbose' : 'error', as in the example above,
does that only in development builds.
Action handlers (actionHandlers)
Lets your app handle deep links, web links and Custom KV commands from campaigns, instead of the SDK's default behavior. See Campaign Actions for the three handlers and how to register them.
Theme (themeMode)
Colors from your project's design system have a light value and a dark value. themeMode picks
which one campaigns use:
| Value | Campaigns use |
|---|---|
auto (default) | The device's light or dark setting. Campaigns on screen switch straight away when the user changes it. |
light | Always the light colors. |
dark | Always the dark colors. |
Colors set directly on a campaign, rather than picked from the design system, look the same in both themes.
Leave it on auto if your app follows the device setting. If your app supports only one theme,
set light or dark so campaigns match it. If your app has its own theme switch, pass the
current choice at initialize, then call Digia.setThemeMode whenever the user changes it.
Campaigns already on screen update without reloading.
- React Native
- Android
- iOS (Swift)
- Flutter
Digia.setThemeMode('dark'); // 'auto' | 'light' | 'dark'
Digia.setThemeMode(DigiaThemeMode.DARK) // AUTO | LIGHT | DARK
Digia.setThemeMode(.dark) // .auto | .light | .dark
Digia.setThemeMode(DigiaThemeMode.dark); // auto | light | dark
Font (fontFamily)
Makes campaign text use one of your app's fonts instead of the font set in the dashboard. Bold, medium and other weights from the campaign design are kept: the SDK picks the matching weight from the family, so include every weight your campaigns use. If the SDK can't find the font, it uses the system font instead, so campaigns still show.
- React Native
- Android
- iOS (Swift)
- Flutter
Pass one name, and make the font available under that name in both native projects. Most campaigns are drawn by the native SDK, so a font that only lives in your JavaScript assets isn't enough.
-
iOS: add the font files to your app target and list them under
UIAppFonts(Fonts provided by application) inInfo.plist. The name is the font's family name, for examplePoppins. -
Android: add a font family file at
android/app/src/main/res/font/poppins.xmlthat lists each weight (see the Android tab). Then register it inMainApplication.onCreate, so guides drawn by React Native use it too:import com.facebook.react.common.assets.ReactFontManagerReactFontManager.getInstance().addCustomFont(this, "Poppins", R.font.poppins)
Pass the name of a font resource in res/font. The SDK turns the name into a resource name:
Poppins finds res/font/poppins.xml, and OpenSans or Open Sans finds open_sans. Use a
font family file that lists each weight:
<font-family xmlns:app="http://schemas.android.com/apk/res-auto">
<font app:fontWeight="400" app:fontStyle="normal" app:font="@font/poppins_regular" />
<font app:fontWeight="500" app:fontStyle="normal" app:font="@font/poppins_medium" />
<font app:fontWeight="700" app:fontStyle="normal" app:font="@font/poppins_bold" />
</font-family>
A single font file such as res/font/poppins.ttf also works, but then every weight is drawn from
that one file. You can also pass a system font family name, such as sans-serif-condensed.
Add the font files to your app target and list them under UIAppFonts (Fonts provided by
application) in Info.plist. Pass the family name, for example Poppins. To check the exact name,
print UIFont.familyNames.
You can also pass the PostScript name of one face, such as Poppins-Bold, but then all campaign
text uses that one face, whatever weight the design asks for.
Pass a family name from your pubspec.yaml, with each weight listed:
flutter:
fonts:
- family: Poppins
fonts:
- asset: assets/fonts/Poppins-Regular.ttf
- asset: assets/fonts/Poppins-Medium.ttf
weight: 500
- asset: assets/fonts/Poppins-Bold.ttf
weight: 700