@digia-engage/core 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -177
- package/package.json +2 -1
- package/react-native.config.js +23 -0
package/README.md
CHANGED
|
@@ -1,203 +1,113 @@
|
|
|
1
|
-
# @digia/
|
|
1
|
+
# @digia-engage/core
|
|
2
2
|
|
|
3
|
-
React Native
|
|
4
|
-
Jetpack Compose UI (dialogs, bottom-sheets) inside React Native applications.
|
|
3
|
+
React Native SDK for **Digia Engage** – renders native Android (Jetpack Compose) and iOS campaign UI (bottom sheets, dialogs, inline banners, tooltips, spotlights) inside React Native applications.
|
|
5
4
|
|
|
6
5
|
> **Platform support**
|
|
7
6
|
> | Platform | Status |
|
|
8
7
|
> |---|---|
|
|
9
8
|
> | Android | ✅ Full support |
|
|
10
|
-
> | iOS |
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## How it works
|
|
15
|
-
|
|
16
|
-
The Digia Engage Android SDK is built entirely with Jetpack Compose. In a
|
|
17
|
-
pure-Android app you wrap your content with the `DigiaHost { }` composable; it
|
|
18
|
-
then manages campaign-driven overlays (dialogs, bottom sheets) on top of your
|
|
19
|
-
content.
|
|
20
|
-
|
|
21
|
-
In a React Native app we cannot embed a Composable directly in the JS tree, so
|
|
22
|
-
the bridge uses two complementary mechanisms:
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
┌─────────────────────────────────────────┐
|
|
26
|
-
│ Android Activity (ReactActivity) │
|
|
27
|
-
│ │
|
|
28
|
-
│ ┌─────────────────────────────────┐ │
|
|
29
|
-
│ │ Android content FrameLayout │ │
|
|
30
|
-
│ │ │ │
|
|
31
|
-
│ │ ┌─────────────────────────┐ │ │
|
|
32
|
-
│ │ │ React Native RootView │ │ │
|
|
33
|
-
│ │ │ (your JS UI) │ │ │
|
|
34
|
-
│ │ └─────────────────────────┘ │ │
|
|
35
|
-
│ │ │ │
|
|
36
|
-
│ │ ┌─────────────────────────┐ │ │
|
|
37
|
-
│ │ │ DigiaHostComposeView │ │ │
|
|
38
|
-
│ │ │ (AbstractComposeView) │ │ │
|
|
39
|
-
│ │ │ hosts DigiaHost { } │ │ │
|
|
40
|
-
│ │ │ ← transparent, no │ │ │
|
|
41
|
-
│ │ │ touch interception │ │ │
|
|
42
|
-
│ │ └─────────────────────────┘ │ │
|
|
43
|
-
│ └─────────────────────────────────┘ │
|
|
44
|
-
│ │
|
|
45
|
-
│ ┌──────────────────────────────────┐ │
|
|
46
|
-
│ │ Compose Dialog window (overlay) │ │
|
|
47
|
-
│ │ Triggered by CEP campaign │ │
|
|
48
|
-
│ └──────────────────────────────────┘ │
|
|
49
|
-
└─────────────────────────────────────────┘
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
1. **`Digia.initialize()`** initialises the SDK and calls `addContentView()`
|
|
53
|
-
to attach a transparent `DigiaHostComposeView` on top of the React Native
|
|
54
|
-
view hierarchy. This is the anchor for the Compose composition.
|
|
55
|
-
|
|
56
|
-
2. **`DigiaHost { }`** inside the `ComposeView` manages `DialogManager` and
|
|
57
|
-
`BottomSheetManager`. When a CEP plugin triggers a campaign, Compose
|
|
58
|
-
renders a `Dialog` or `ModalBottomSheet` – these are **separate Android
|
|
59
|
-
windows** that appear on top of everything, including React Native content.
|
|
60
|
-
|
|
61
|
-
3. **`<DigiaHostView>`** is an optional React Native component you can place in
|
|
62
|
-
your component tree (e.g. as `StyleSheet.absoluteFill`) if you prefer a
|
|
63
|
-
declarative, component-based mount point instead of the auto-mount.
|
|
9
|
+
> | iOS | ✅ Full support |
|
|
64
10
|
|
|
65
11
|
---
|
|
66
12
|
|
|
67
13
|
## Installation
|
|
68
14
|
|
|
69
15
|
```sh
|
|
70
|
-
|
|
71
|
-
npm install @digia/engage-react-native
|
|
72
|
-
|
|
73
|
-
# yarn
|
|
74
|
-
yarn add @digia/engage-react-native
|
|
16
|
+
npm install @digia-engage/core
|
|
75
17
|
```
|
|
76
18
|
|
|
77
|
-
React Native CLI auto-linking handles the rest.
|
|
19
|
+
React Native CLI auto-linking handles the rest. Rebuild the native app after installing:
|
|
78
20
|
|
|
79
21
|
```sh
|
|
80
|
-
npx react-native
|
|
22
|
+
npx react-native run-android
|
|
81
23
|
# or
|
|
82
24
|
cd android && ./gradlew assembleDebug
|
|
83
25
|
```
|
|
84
26
|
|
|
85
|
-
### Android – host app
|
|
27
|
+
### Android – host app dependency
|
|
86
28
|
|
|
87
|
-
|
|
88
|
-
(or include it via your local Maven / private registry):
|
|
29
|
+
Add the Digia Engage Android SDK to `android/app/build.gradle.kts`:
|
|
89
30
|
|
|
90
|
-
```
|
|
31
|
+
```kotlin
|
|
91
32
|
dependencies {
|
|
92
|
-
implementation
|
|
33
|
+
implementation("tech.digia:engage:1.1.0")
|
|
93
34
|
}
|
|
94
35
|
```
|
|
95
36
|
|
|
96
|
-
If you are working inside the monorepo and building locally, add the `:digia-ui`
|
|
97
|
-
project instead:
|
|
98
|
-
|
|
99
|
-
```groovy
|
|
100
|
-
implementation(project(':digia-ui'))
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### iOS
|
|
104
|
-
|
|
105
|
-
iOS is a no-op stub. All methods resolve immediately without error.
|
|
106
|
-
|
|
107
37
|
---
|
|
108
38
|
|
|
109
39
|
## Usage
|
|
110
40
|
|
|
111
41
|
### 1 – Initialise the SDK
|
|
112
42
|
|
|
113
|
-
Call `Digia.initialize()` once
|
|
114
|
-
`App.tsx`):
|
|
43
|
+
Call `Digia.initialize()` once at app startup, before registering any CEP plugin:
|
|
115
44
|
|
|
116
45
|
```tsx
|
|
117
|
-
import
|
|
118
|
-
import {
|
|
119
|
-
import { Digia } from '@digia/engage-react-native';
|
|
46
|
+
import { useEffect } from 'react';
|
|
47
|
+
import { Digia } from '@digia-engage/core';
|
|
120
48
|
|
|
121
|
-
export
|
|
49
|
+
export function RootApp() {
|
|
122
50
|
useEffect(() => {
|
|
123
|
-
|
|
124
|
-
apiKey: '
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
51
|
+
(async () => {
|
|
52
|
+
await Digia.initialize({ apiKey: 'YOUR_ACCESS_KEY' });
|
|
53
|
+
// Register your CEP plugin here (e.g. DigiaCleverTapPlugin)
|
|
54
|
+
})().catch(console.error);
|
|
128
55
|
}, []);
|
|
129
56
|
|
|
130
|
-
return <
|
|
57
|
+
return <AppNavigator />;
|
|
131
58
|
}
|
|
132
59
|
```
|
|
133
60
|
|
|
134
|
-
|
|
135
|
-
overlay host to the Activity. You do **not** need to add `<DigiaHostView>`
|
|
136
|
-
unless you want an explicit component-based mount point.
|
|
61
|
+
### 2 – Mount the overlay host
|
|
137
62
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
Wire `setCurrentScreen()` to your navigation state so the SDK can trigger
|
|
141
|
-
campaigns based on the active screen:
|
|
63
|
+
Place `<DigiaHostView>` at the app root so nudge campaigns (bottom sheets, dialogs, tooltips, spotlights) render above all content:
|
|
142
64
|
|
|
143
65
|
```tsx
|
|
144
|
-
import {
|
|
145
|
-
import {
|
|
66
|
+
import { StyleSheet, View } from 'react-native';
|
|
67
|
+
import { DigiaHostView } from '@digia-engage/core';
|
|
68
|
+
import { Stack } from 'expo-router';
|
|
146
69
|
|
|
147
|
-
|
|
148
|
-
|
|
70
|
+
export default function RootLayout() {
|
|
71
|
+
return (
|
|
72
|
+
<View style={styles.root}>
|
|
73
|
+
<DigiaHostView style={StyleSheet.absoluteFill} />
|
|
74
|
+
<Stack />
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
149
78
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const currentRoute = navRef.getCurrentRoute();
|
|
154
|
-
if (currentRoute) {
|
|
155
|
-
Digia.setCurrentScreen(currentRoute.name);
|
|
156
|
-
}
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
79
|
+
const styles = StyleSheet.create({
|
|
80
|
+
root: { flex: 1 },
|
|
81
|
+
});
|
|
159
82
|
```
|
|
160
83
|
|
|
161
|
-
### 3 –
|
|
84
|
+
### 3 – Track screen changes
|
|
162
85
|
|
|
163
|
-
|
|
86
|
+
Wire `setCurrentScreen()` to your navigation library so the SDK can trigger screen-scoped campaigns:
|
|
164
87
|
|
|
165
88
|
```tsx
|
|
166
|
-
import { Digia } from '@digia/
|
|
89
|
+
import { Digia } from '@digia-engage/core';
|
|
167
90
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
91
|
+
// React Navigation example:
|
|
92
|
+
<NavigationContainer
|
|
93
|
+
onStateChange={() => {
|
|
94
|
+
const route = navRef.getCurrentRoute();
|
|
95
|
+
if (route) Digia.setCurrentScreen(route.name);
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
176
98
|
```
|
|
177
99
|
|
|
178
|
-
### 4 –
|
|
100
|
+
### 4 – Add inline slots
|
|
179
101
|
|
|
180
|
-
|
|
181
|
-
`initialize()` auto-mount and place `<DigiaHostView>` at the root of your
|
|
182
|
-
component tree:
|
|
102
|
+
Place `<DigiaSlotView>` wherever you want inline campaign content (banners, cards):
|
|
183
103
|
|
|
184
104
|
```tsx
|
|
185
|
-
import
|
|
186
|
-
import { StyleSheet, View } from 'react-native';
|
|
187
|
-
import { DigiaHostView } from '@digia/engage-react-native';
|
|
188
|
-
|
|
189
|
-
export default function App() {
|
|
190
|
-
return (
|
|
191
|
-
<View style={styles.root}>
|
|
192
|
-
{/* DigiaHostView must be above all other content in z-order */}
|
|
193
|
-
<DigiaHostView style={StyleSheet.absoluteFill} />
|
|
105
|
+
import { DigiaSlotView } from '@digia-engage/core';
|
|
194
106
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const styles = StyleSheet.create({ root: { flex: 1 } });
|
|
107
|
+
<DigiaSlotView
|
|
108
|
+
placementKey="home_hero_banner"
|
|
109
|
+
style={{ width: '100%', height: 180 }}
|
|
110
|
+
/>
|
|
201
111
|
```
|
|
202
112
|
|
|
203
113
|
---
|
|
@@ -208,9 +118,10 @@ const styles = StyleSheet.create({ root: { flex: 1 } });
|
|
|
208
118
|
|
|
209
119
|
| Method | Signature | Description |
|
|
210
120
|
|---|---|---|
|
|
211
|
-
| `initialize` | `(config: DigiaConfig) => Promise<void>` | Initialise the SDK
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
121
|
+
| `initialize` | `(config: DigiaConfig) => Promise<void>` | Initialise the SDK. Call once at app startup. |
|
|
122
|
+
| `register` | `(plugin: DigiaPlugin) => void` | Register a CEP plugin (e.g. `DigiaCleverTapPlugin`). |
|
|
123
|
+
| `unregister` | `(plugin: DigiaPlugin \| string) => void` | Unregister a plugin and call its `teardown()`. |
|
|
124
|
+
| `setCurrentScreen` | `(name: string) => void` | Notify the SDK of the current screen name. |
|
|
214
125
|
|
|
215
126
|
### `DigiaConfig`
|
|
216
127
|
|
|
@@ -220,46 +131,22 @@ const styles = StyleSheet.create({ root: { flex: 1 } });
|
|
|
220
131
|
| `environment` | `'production' \| 'sandbox'` | `'production'` | Target environment. |
|
|
221
132
|
| `logLevel` | `'none' \| 'error' \| 'verbose'` | `'error'` | Log verbosity. |
|
|
222
133
|
|
|
223
|
-
### `CreateInitialPageOptions`
|
|
224
|
-
|
|
225
|
-
Empty interface — reserved for future optional arguments.
|
|
226
|
-
|
|
227
134
|
### `<DigiaHostView>`
|
|
228
135
|
|
|
229
|
-
|
|
136
|
+
Transparent overlay that hosts Digia-rendered campaign UI (dialogs, bottom sheets, tooltips, spotlights) above app content. Mount once at the app root.
|
|
230
137
|
|
|
231
138
|
| Prop | Type | Description |
|
|
232
139
|
|---|---|---|
|
|
233
|
-
| `style` | `ViewStyle?` |
|
|
140
|
+
| `style` | `ViewStyle?` | Style for the overlay view. Typically `StyleSheet.absoluteFill`. |
|
|
234
141
|
|
|
235
|
-
|
|
142
|
+
### `<DigiaSlotView>`
|
|
236
143
|
|
|
237
|
-
|
|
144
|
+
Renders inline campaign content (banners, cards) at a named placement. Collapses to zero height when no campaign is active for the slot.
|
|
238
145
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
│ ├── types.ts ← TypeScript interfaces
|
|
244
|
-
│ ├── Digia.ts ← High-level JS SDK wrapper
|
|
245
|
-
│ ├── NativeDigiaEngage.ts ← Low-level native module binding
|
|
246
|
-
│ └── DigiaHostView.tsx ← <DigiaHostView> React component
|
|
247
|
-
│
|
|
248
|
-
├── android/
|
|
249
|
-
│ ├── build.gradle ← Android library build config
|
|
250
|
-
│ └── src/main/java/com/digia/engage/rn/
|
|
251
|
-
│ ├── DigiaPackage.kt ← ReactPackage (registers module + view)
|
|
252
|
-
│ ├── DigiaModule.kt ← NativeModule (initialize, setCurrentScreen, createInitialPage)
|
|
253
|
-
│ ├── DigiaViewManager.kt ← ViewManager for <DigiaHostView>
|
|
254
|
-
│ └── DigiaHostComposeView.kt ← AbstractComposeView hosting DigiaHost { }
|
|
255
|
-
│
|
|
256
|
-
├── ios/
|
|
257
|
-
│ └── DigiaEngageModule.m ← iOS no-op stub
|
|
258
|
-
│
|
|
259
|
-
├── DigiaEngageReactNative.podspec
|
|
260
|
-
├── react-native.config.js ← Auto-linking config
|
|
261
|
-
└── package.json
|
|
262
|
-
```
|
|
146
|
+
| Prop | Type | Description |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `placementKey` | `string` | Must match the placement key in your CEP campaign. |
|
|
149
|
+
| `style` | `ViewStyle?` | An explicit height is required — the slot is not visible without one. |
|
|
263
150
|
|
|
264
151
|
---
|
|
265
152
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digia-engage/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "React Native bridge for Digia Engage – renders native Android Compose UI inside React Native apps",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"android",
|
|
14
14
|
"ios",
|
|
15
15
|
"*.podspec",
|
|
16
|
+
"react-native.config.js",
|
|
16
17
|
"!lib/typescript/example",
|
|
17
18
|
"!android/.gradle",
|
|
18
19
|
"!android/build",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-native.config.js
|
|
3
|
+
*
|
|
4
|
+
* Configures React Native CLI auto-linking for @digia/engage-react-native.
|
|
5
|
+
* This tells the RN CLI where to find the Android library module and the
|
|
6
|
+
* iOS podspec so that `npx react-native link` / auto-linking works without
|
|
7
|
+
* any manual steps in host app project files.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = {
|
|
10
|
+
dependency: {
|
|
11
|
+
platforms: {
|
|
12
|
+
android: {
|
|
13
|
+
// Path to the Android library module (relative to this package root)
|
|
14
|
+
sourceDir: './android',
|
|
15
|
+
packageImportPath: 'import com.digia.engage.rn.DigiaPackage;',
|
|
16
|
+
packageInstance: 'new DigiaPackage()',
|
|
17
|
+
},
|
|
18
|
+
ios: {
|
|
19
|
+
podspecPath: './DigiaEngageReactNative.podspec',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|