@digia-engage/core

中文文档
3.3.1发布于 2026/11/05BUSL-1.1TypeScriptESM + CJS近 30 天下载 2525

React Native bridge for Digia Engage – renders native Android Compose UI inside React Native apps

原始使用文档
文档目录20 节
  1. How it works
  2. Requirements
  3. Installation
  4. iOS pods
  5. Usage
  6. 1 — Initialize the SDK
  7. 2 — Mount <DigiaHost />
  8. 3 — Track screen changes
  9. 4 — Add anchors for guide campaigns
  10. 5 — Add slots for inline campaigns
  11. 6 — Trigger campaigns
  12. 7 — (Optional) Handle actions
  13. 8 — (Optional) Identify users
  14. API Reference
  15. Digia
  16. DigiaConfig
  17. <DigiaHost />
  18. <DigiaAnchorView>
  19. <DigiaSlotView>
  20. License

@digia-engage/core

React Native SDK for Digia Engage. It renders in-app experiences (nudges, guides, surveys, and inline content) in React Native apps on Android and iOS.


How it works

@digia-engage/core wraps the native Digia Engage Android and iOS SDKs. The native SDKs load campaigns, decide what to show, and render nudges, surveys, and inline content. Tooltip and spotlight guides are rendered in React Native by <DigiaHost />, anchored to your <DigiaAnchorView> elements.

Campaigns are triggered by a CEP (CleverTap, WebEngage, or MoEngage, through its @digia-engage/* package) or by your app through Digia.triggerCampaign().

Campaign typeRendered by
Nudge (dialog, bottom sheet)Native SDK
SurveyNative SDK
Inline (banners, carousels)Native SDK, inside <DigiaSlotView>
Guide (tooltip, spotlight)React Native, inside <DigiaHost />

Requirements

Minimum
AndroidminSdk 24; Digia Engage Android SDK 3.x (pulled in automatically)
iOSiOS 15.0; Digia Engage iOS SDK 4.x (pulled in automatically)

Installation

npm install @digia-engage/core
# or
yarn add @digia-engage/core

Autolinking handles the native setup.

iOS pods

The Digia Engage iOS SDK is published to the Digia CocoaPods spec repo. Point CocoaPods at it.

Expo: add the config plugin to app.json, then run npx expo prebuild:

{ "expo": { "plugins": ["@digia-engage/core"] } }

Bare React Native: add these lines to the top of ios/Podfile, keeping this order:

source 'https://github.com/Digia-Technology-Private-Limited/digia-podspecs.git'
source 'https://cdn.cocoapods.org/'

Then install pods and rebuild the app:

cd ios && pod install

To use a CEP, also install its package: @digia-engage/clevertap, @digia-engage/webengage, or @digia-engage/moengage.


Usage

1 — Initialize the SDK

Call Digia.initialize() once, as early as possible (top of App.tsx):

import { Digia } from '@digia-engage/core';

await Digia.initialize({
  apiKey: 'YOUR_API_KEY',
  environment: 'production', // or 'sandbox'
  logLevel: 'error',
});

initialize() waits up to 2 seconds for campaigns to load and does not reject if loading fails.

Custom fonts

Embed the font faces your app needs using Expo's expo-font config plugin or your native projects, then pass the registered family name to Digia Engage. Dashboard-provided weights are applied automatically.

await Digia.initialize({
  apiKey: 'YOUR_API_KEY',
  fontFamily: 'Inter',
});

The family must be registered as a native multi-face family. If the requested face is unavailable, the operating system performs its normal font fallback.

2 — Mount <DigiaHost />

Place <DigiaHost /> once at the root of your component tree, after your navigation container. It renders tooltip and spotlight guides.

// app/_layout.tsx (Expo Router) or App.tsx
import { DigiaHost } from '@digia-engage/core';

export default function RootLayout() {
  return (
    <>
      <Stack />
      <DigiaHost />
    </>
  );
}

3 — Track screen changes

import { Digia } from '@digia-engage/core';

<NavigationContainer
  onStateChange={() => {
    const route = navRef.getCurrentRoute();
    if (route) Digia.setCurrentScreen(route.name);
  }}
>

4 — Add anchors for guide campaigns

Wrap any UI element you want a tooltip or spotlight to point at:

import { DigiaAnchorView } from '@digia-engage/core';

<DigiaAnchorView anchorKey="home_banner_btn">
  <Button title="Banner" />
</DigiaAnchorView>

5 — Add slots for inline campaigns

import { DigiaSlotView } from '@digia-engage/core';

// Auto-sizes to the content height
<DigiaSlotView placementKey="home_banner" />

6 — Trigger campaigns

With a CEP — install its package and register it after initialize():

import { DigiaCleverTapPlugin } from '@digia-engage/clevertap';

await Digia.initialize({ apiKey: 'YOUR_API_KEY' });
Digia.register(new DigiaCleverTapPlugin());

register() rejects if the CEP package isn't installed or linked. Each CEP package's README lists any extra setup it needs.

From your app — show a campaign by key:

const { accepted, dropReason } = await Digia.triggerCampaign('welcome_tour');
if (!accepted) console.warn(`Not shown: ${dropReason}`);

dropReason explains a refusal, for example frequency_capped, screen_not_targeted, unknown_campaign_key, or not_ready while campaigns are still loading. Pass a second argument to override the campaign's variables for this delivery.

7 — (Optional) Handle actions

Register only the actions your app owns. A configured handler suppresses SDK fallback:

await Digia.initialize({
  apiKey: 'YOUR_API_KEY',
  actionHandlers: {
    customKV: (payload) => handleCustomAction(payload),
    deepLink: (url) => router.push(url),
    openURL: (url) => openInAppBrowser(url),
  },
  linking: {
    routeViaSystemLinking: true,
    inAppBrowser: defaultInAppBrowser, // requires react-native-inappbrowser-reborn
  },
});

Handlers can be replaced after initialization and cleared when a screen stops owning the action:

Digia.setCustomKVHandler((payload) => handleCustomAction(payload));
Digia.setCustomKVHandler(null);

8 — (Optional) Identify users

Digia.setUserId('user-123'); // after login
Digia.clearUserId();         // on logout
Digia.clearAllInlineContent(); // drop the previous user's inline content

API Reference

Digia

MethodSignatureDescription
initialize(config: DigiaConfig) => Promise<void>Initialize the SDK. Call once before anything else.
register(plugin: DigiaPlugin) => Promise<void>Attach a CEP plugin from its @digia-engage/* package. Call it after initialize().
unregister(plugin: DigiaPlugin | string) => voidForget a registration so it can be registered again. The CEP stays attached until the app restarts.
triggerCampaign(campaignKey: string, variables?: Record<string, string>) => Promise<{ presentationId: string; accepted: boolean; dropReason: string | null }>Show a campaign by key.
setCurrentScreen(name: string) => voidNotify the SDK of the active screen.
setThemeMode(mode: 'auto' | 'light' | 'dark') => voidChange campaign appearance.
setUserId(userId: string) => voidAssociate a user ID with analytics. Call after login.
clearUserId() => voidClear the user ID. Call on logout.
clearInlineContent(...placementKeys: string[]) => voidClear inline content for the given placements.
clearAllInlineContent() => voidClear inline content in every placement.
setCustomKVHandler(handler: CustomKVHandler | null) => voidReplace or clear the Custom KV override.
setDeepLinkHandler(handler: DeepLinkHandler | null) => voidReplace or clear the deep-link override.
setOpenURLHandler(handler: OpenURLHandler | null) => voidReplace or clear the external URL override.
handleDeepLink(url: string) => booleanOpens the debug settings screen if url is the SDK's debug deep link; returns false otherwise.
openDebugSettings() => voidOpen the debug-only settings screen. No-op in release builds.
registerAnchor / unregisterAnchor—Deprecated no-ops. <DigiaAnchorView> registers itself.

DigiaConfig

PropTypeDefaultDescription
apiKeystring—Required. Your Digia Engage API key.
environment'production' | 'sandbox''production'Target environment.
logLevel'none' | 'error' | 'verbose''error'Log verbosity.
themeMode'auto' | 'light' | 'dark''auto'Campaign appearance. auto follows the system theme.
fontFamilystring—Registered font family used by all campaign text.
actionHandlersDigiaActionHandlers{}Typed Custom KV, deep-link, and open-URL overrides.
linking.routeViaSystemLinkingbooleantrueUse Linking.openURL for URL actions.
linking.inAppBrowserInAppBrowserAdapter—Required for open_url with presentation: 'in_app'.

<DigiaHost />

No props. Renders tooltip and spotlight guides. Place it once at the app root.

<DigiaAnchorView>

PropTypeDescription
anchorKeystringRequired. Must match the step's anchorKey in the campaign config.
...ViewProps—All standard React Native View props are forwarded.

<DigiaSlotView>

Renders inline campaign content (banners, cards) at a named placement. Collapses to zero height when no campaign is active for the slot.

PropTypeDescription
placementKeystringRequired. Must match the campaign's slotKey.
styleViewStyle?Pass an explicit height to fix size; otherwise auto-sizes.

License

Business Source License 1.1 (BUSL-1.1) © Tinkerbox Technology Private Limited — see LICENSE

版本与发布记录

@digia-engage/core 共发布 57 个版本,首次发布于 2026/03/20;过去 12 个月发布了 57 个版本。

版本发布日期距今
3.3.1latest2026/11/057 天前
3.3.02026/11/048 天前
3.2.02026/11/039 天前
2.22.3release-2.222026/10/3013 天前
3.1.12026/10/2914 天前
3.1.02026/10/2914 天前

其他发布通道:beta → 1.0.0-beta.6,rc → 2.0.0-rc.1,next → 2.0.0-rc.2,release-2.22 → 2.22.3。

关于 @digia-engage/core 的常见问题

@digia-engage/core 是什么?

React Native bridge for Digia Engage – renders native Android Compose UI inside React Native apps

如何安装 @digia-engage/core?

在项目目录运行 npm install @digia-engage/core,或使用 pnpm add / yarn add / bun add。

@digia-engage/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@digia-engage/core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@digia-engage/core 可以商用吗?

@digia-engage/core 使用 BUSL-1.1 许可。声明的许可为 BUSL-1.1,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@digia-engage/core 的下载量有多少?

根据 npm 官方下载统计,@digia-engage/core 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,525 次,日均约 84 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@digia-engage/core 还在维护吗?

最新版本 3.3.1 发布于 2026/11/05(7 天前);至今共发布 57 个版本,其中过去 12 个月发布了 57 个;首次发布于 2026/03/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。