@digia-engage/clevertap
v3.0.0
Published
Shell package carrying the native Digia CEP plugin for CleverTap (Android/iOS) into a React Native app via autolinking. All CEP logic is native — see README.md.
Downloads
416
Readme
@digia-engage/clevertap
CleverTap CEP plugin for Digia Engage on React Native.
the integration runs entirely in the native Digia Engage CleverTap
plugin (tech.digia:engage-clevertap on Android, DigiaEngageCleverTap on iOS),
which this package adds to your app through autolinking. Template registration,
campaign delivery, and reporting back to CleverTap all happen natively.
Digia.register(new DigiaCleverTapPlugin()) attaches it.
Installation
npm install @digia-engage/clevertap @digia-engage/coreclevertap-react-native is no longer a dependency of this package. Keep it
installed if your app uses CleverTap's own RN SDK directly (push notifications,
custom events, etc.) — this plugin no longer touches it.
Usage
import { useEffect } from 'react';
import { Digia } from '@digia-engage/core';
import { DigiaCleverTapPlugin } from '@digia-engage/clevertap';
export function RootApp() {
useEffect(() => {
(async () => {
await Digia.initialize({ apiKey: 'YOUR_ACCESS_KEY' });
Digia.register(new DigiaCleverTapPlugin());
})().catch(console.error);
}, []);
return <AppNavigator />;
}Screen tracking
Digia.setCurrentScreen('Home');Forwarded to CleverTap natively so CleverTap can evaluate screen-scoped campaigns.
Migration to v3 (native shell) — read this before upgrading
v3 deletes this package's entire TypeScript implementation
(CleverTapClient, CleverTapPayloadMapper, the slot-lifecycle logic in
DigiaCleverTapPlugin, the bundled digia.json, and their tests). If you were
constructing the plugin with a client —
new DigiaCleverTapPlugin({ cleverTap: createCleverTapClient(CleverTap) }) —
drop the argument; createCleverTapClient no longer exists.
One required native setup step
CleverTap resolves custom templates when its instance is created — earlier
than any RN module's init can run. Your app must call
DigiaCleverTapPlugin.prepareCleverTapCustomTemplates() from both:
- Android —
Application.onCreate(), beforeCleverTapAPIis created. - iOS —
AppDelegate.application(_:didFinishLaunchingWithOptions:), before CleverTap initialises.
This is one line in each file. CleverTap's own React Native SDK already needs
setup in both files, so you are adding one more line where you already have code.
Skipping it means CleverTap silently filters out custom-template campaigns
(DigiaTemplate) before they ever reach Digia.
prepareCleverTapCustomTemplates() is a native method on the native
plugin (DigiaCleverTapPlugin in com.digia.engage.clevertap / the Swift
DigiaEngageCleverTap module) — it is not exposed to JS, because it must run
before the RN bridge exists.
digia.json is gone
Previously this package bundled digia.json and registered the DigiaTemplate
custom template from it at load time (Android: a ContentProvider; iOS: an
Objective-C +load). The native plugin now registers the same template in
code. Registering it twice throws CleverTapCustomTemplateException at
startup — so if you're upgrading from an older @digia-engage/clevertap, make
sure you don't have a stray digia.json or old init class hanging around
after the upgrade (a clean pod install / Gradle sync clears it).
Peer version note
Requires @digia-engage/core 3.x. Older cores can't attach the native plugin.
Compatibility
| Dependency | Supported range |
|---|---|
| @digia-engage/core | >= 3.0.0, < 4.0.0 |
| Native Android plugin | engage-clevertap >= 3.0.0, < 4.0.0 |
| Native iOS plugin | DigiaEngageCleverTap >= 2.0.0, < 3.0.0 |
| CleverTap Android SDK | >= 7.3.1, < 9.0.0 (tested through 8.4.1) |
| CleverTap iOS SDK | >= 7.5.1, < 8.0.0 |
If the app also uses clevertap-react-native, verify that wrapper release's
native Android and iOS pins both fall inside these windows.
Template
The DigiaTemplate custom template has three arguments (registered natively,
documented here for reference when building campaigns on the CleverTap
dashboard):
| Argument | Type | Default |
|----------------------|--------|---------|
| digia_campaign_key | string | "" |
| variables | string | "{}" |
| action | action | Configure Custom → DigiaPrimaryClick |
API
DigiaCleverTapPlugin
| Member | Description |
|---|---|
| constructor(options?) | options is accepted and ignored — kept for source compatibility. |
| nativePluginId | 'clevertap'. Read by Digia.register() to attach the native plugin. |
License
Business Source License 1.1 (BUSL-1.1) © Tinkerbox Technology Private Limited — see LICENSE
