@customerglu/react-native-customerglu 4.0.0 → 4.1.2
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 +214 -19
- package/ReactNativeCustomerglu.podspec +1 -1
- package/android/build.gradle +2 -3
- package/ios/IosBannerView.mm +1 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -1,30 +1,225 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h1 align="center">CustomerGlu React Native SDK</h1>
|
|
3
|
+
<p align="center">In-app gamification, rewards, and engagement campaigns for React Native — unified API across iOS and Android.</p>
|
|
4
|
+
</p>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://www.npmjs.com/package/@customerglu/react-native-customerglu"><img src="https://img.shields.io/npm/v/@customerglu/react-native-customerglu?label=npm&color=blue" alt="npm"></a>
|
|
8
|
+
<a href="https://docs.customerglu.com/sdk/mobile-sdks#react-native"><img src="https://img.shields.io/badge/docs-customerglu.com-green" alt="Documentation"></a>
|
|
9
|
+
<a href="https://github.com/customerglu/CG-SDK-React-Native/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-lightgrey" alt="License"></a>
|
|
10
|
+
</p>
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
<p align="center">
|
|
13
|
+
<b>All CustomerGlu SDKs share the same version number.</b><br>
|
|
14
|
+
iOS <code>4.1.2</code> · Android <code>4.1.2</code> · React Native <code>4.1.2</code>
|
|
15
|
+
</p>
|
|
6
16
|
|
|
7
|
-
|
|
8
|
-
Supports IOS 12.0+ and requires Xcode 12 or above to build.
|
|
17
|
+
---
|
|
9
18
|
|
|
10
|
-
|
|
11
|
-
Supports API 21 and above. Please ensure the minSDKVersion in the app's build.gradle file reflects the same.
|
|
19
|
+
## Table of Contents
|
|
12
20
|
|
|
21
|
+
- [Requirements](#requirements)
|
|
22
|
+
- [Installation](#installation)
|
|
23
|
+
- [Quick Start](#quick-start)
|
|
24
|
+
- [Banner Widgets](#banner-widgets)
|
|
25
|
+
- [Features](#features)
|
|
26
|
+
- [What's New in 4.1.2](#whats-new-in-400)
|
|
27
|
+
- [Troubleshooting](#troubleshooting)
|
|
28
|
+
- [Native SDKs](#native-sdks)
|
|
29
|
+
- [Documentation](#documentation)
|
|
13
30
|
|
|
14
|
-
|
|
31
|
+
---
|
|
15
32
|
|
|
16
|
-
|
|
17
|
-
Add the CustomerGlu React Native plugin in package.json file
|
|
18
|
-
```
|
|
19
|
-
"@customerglu/react-native-customerglu": "^3.1.2"
|
|
20
|
-
```
|
|
33
|
+
## Requirements
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
| Platform | Minimum |
|
|
36
|
+
|----------|---------|
|
|
37
|
+
| React Native | 0.71+ |
|
|
38
|
+
| iOS | 14.0+ / Xcode 13+ |
|
|
39
|
+
| Android | API 21 (Android 5.0)+ |
|
|
40
|
+
| Node.js | 16+ |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### npm
|
|
47
|
+
|
|
48
|
+
```bash
|
|
25
49
|
npm install @customerglu/react-native-customerglu
|
|
26
|
-
```
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Yarn
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
yarn add @customerglu/react-native-customerglu
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### iOS Setup
|
|
59
|
+
|
|
60
|
+
Install the native CocoaPods dependency:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cd ios && pod install && cd ..
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The React Native SDK automatically pulls in the native iOS SDK (`CustomerGlu 4.1.2`) via CocoaPods.
|
|
67
|
+
|
|
68
|
+
### Android Setup
|
|
69
|
+
|
|
70
|
+
The native Android SDK (`com.customerglu:CustomerGluLibrary:4.1.2`) is resolved automatically via Maven Central.
|
|
71
|
+
|
|
72
|
+
Ensure `mavenCentral()` is in your **project-level** `build.gradle` (or `settings.gradle`):
|
|
73
|
+
|
|
74
|
+
```gradle
|
|
75
|
+
// build.gradle (project)
|
|
76
|
+
allprojects {
|
|
77
|
+
repositories {
|
|
78
|
+
mavenCentral()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```gradle
|
|
84
|
+
// OR settings.gradle (newer projects)
|
|
85
|
+
dependencyResolutionManagement {
|
|
86
|
+
repositories {
|
|
87
|
+
mavenCentral()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
No additional Android configuration is required.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Quick Start
|
|
97
|
+
|
|
98
|
+
### 1. Configure Your Write Key
|
|
99
|
+
|
|
100
|
+
#### iOS — `Info.plist`
|
|
101
|
+
|
|
102
|
+
```xml
|
|
103
|
+
<key>CUSTOMERGLU_WRITE_KEY</key>
|
|
104
|
+
<string>YOUR_WRITE_KEY</string>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Android — `AndroidManifest.xml`
|
|
108
|
+
|
|
109
|
+
```xml
|
|
110
|
+
<meta-data
|
|
111
|
+
android:name="CUSTOMERGLU_WRITE_KEY"
|
|
112
|
+
android:value="YOUR_WRITE_KEY" />
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
You can find your write key in the [CustomerGlu Dashboard](https://dashboard.customerglu.com) under **Settings → SDK Keys**.
|
|
116
|
+
|
|
117
|
+
### 2. Register a User
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { CustomerGlu } from '@customerglu/react-native-customerglu';
|
|
121
|
+
|
|
122
|
+
// Register user (call once after login / app launch)
|
|
123
|
+
await CustomerGlu.registerDevice('user-123');
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 3. Common Operations
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
// Open the rewards wallet
|
|
130
|
+
CustomerGlu.openWallet();
|
|
131
|
+
|
|
132
|
+
// Load all campaigns
|
|
133
|
+
CustomerGlu.loadAllCampaigns();
|
|
134
|
+
|
|
135
|
+
// Send a custom event
|
|
136
|
+
CustomerGlu.sendEventData({
|
|
137
|
+
eventName: 'purchase',
|
|
138
|
+
eventProperties: { amount: 99 },
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Update user attributes
|
|
142
|
+
CustomerGlu.updateProfile({ plan: 'premium' });
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Banner Widgets
|
|
148
|
+
|
|
149
|
+
Embed native banner widgets in your React Native views using `CGBannerWidget`:
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import { CGBannerWidget } from '@customerglu/react-native-customerglu';
|
|
153
|
+
|
|
154
|
+
function HomeScreen() {
|
|
155
|
+
return (
|
|
156
|
+
<CGBannerWidget
|
|
157
|
+
bannerId="home_rewards_banner"
|
|
158
|
+
style={{ width: '100%' }}
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The SDK handles rendering, styling, native widget inflation, and click actions automatically based on your dashboard configuration. Banner height is managed dynamically — native widgets measure their content and resize the React Native container.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Features
|
|
169
|
+
|
|
170
|
+
| Feature | Description |
|
|
171
|
+
|---------|-------------|
|
|
172
|
+
| **Cross-platform** | Single TypeScript API for iOS and Android |
|
|
173
|
+
| **Entry Points** | Floating buttons, banners, embedded views |
|
|
174
|
+
| **Native Widgets** | DYNAMIC_MULTISTEP progress widgets rendered natively (no WebView) |
|
|
175
|
+
| **Campaigns** | Bottom sheets, popups, full-screen campaigns |
|
|
176
|
+
| **Real-time** | SSE-based live nudges and state updates |
|
|
177
|
+
| **Deep Linking** | Campaign navigation handling |
|
|
178
|
+
| **Analytics** | Event tracking and diagnostics |
|
|
179
|
+
| **Multi-region** | ME, US, and default API endpoints — resolved automatically |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## What's New in 4.1.2
|
|
184
|
+
|
|
185
|
+
- **DYNAMIC_MULTISTEP native rendering** — three widget variants (MS1, MS2, MS3) rendered natively on both iOS and Android instead of WebView for better performance and native feel
|
|
186
|
+
- **Auto-height bridge** — native widgets broadcast measured height via `CGBANNER_FINAL_HEIGHT` to resize React Native containers dynamically
|
|
187
|
+
- **iOS overflow support** — `clipsToBounds = NO` on the bridge view enables MS3 expand/collapse animation overflow
|
|
188
|
+
- **19 configurable nativeStyle fields** — colors, fonts, border radius, shimmer, and more — all controlled via dashboard
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Troubleshooting
|
|
193
|
+
|
|
194
|
+
| Issue | Solution |
|
|
195
|
+
|-------|----------|
|
|
196
|
+
| `pod install` fails | Run `pod repo update` then retry; ensure Xcode CLT is installed |
|
|
197
|
+
| Android build error | Verify `mavenCentral()` in repositories; ensure Java 17+ |
|
|
198
|
+
| Banner not showing | Check `bannerId` matches dashboard config; ensure `registerDevice` succeeded |
|
|
199
|
+
| Height not updating | Confirm `CGBannerWidget` has `overflow: 'visible'` in its style if using MS3 expand |
|
|
200
|
+
| Module not found | Clear caches: `npx react-native start --reset-cache` |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Native SDKs
|
|
205
|
+
|
|
206
|
+
The React Native SDK wraps the native SDKs. For advanced customization or standalone native apps:
|
|
207
|
+
|
|
208
|
+
| Platform | Package | Install |
|
|
209
|
+
|----------|---------|---------|
|
|
210
|
+
| **iOS** | `CustomerGlu` | [CocoaPods](https://cocoapods.org/pods/CustomerGlu) · [SPM](https://github.com/customerglu/CG-iOS-SDK) |
|
|
211
|
+
| **Android** | `com.customerglu:CustomerGluLibrary:4.1.2` | [Maven Central](https://central.sonatype.com/artifact/com.customerglu/CustomerGluLibrary) |
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Documentation
|
|
216
|
+
|
|
217
|
+
Full SDK docs, guides, and API reference:
|
|
218
|
+
|
|
219
|
+
**[https://docs.customerglu.com/sdk/mobile-sdks#react-native](https://docs.customerglu.com/sdk/mobile-sdks#react-native)**
|
|
220
|
+
|
|
221
|
+
---
|
|
27
222
|
|
|
28
|
-
|
|
223
|
+
## License
|
|
29
224
|
|
|
30
|
-
|
|
225
|
+
[MIT](LICENSE)
|
|
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
|
|
20
20
|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
21
21
|
s.private_header_files = "ios/generated/**/*.h"
|
|
22
|
-
s.dependency "CustomerGlu", "4.
|
|
22
|
+
s.dependency "CustomerGlu", "4.1.2"
|
|
23
23
|
|
|
24
24
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
25
25
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/android/build.gradle
CHANGED
|
@@ -101,9 +101,8 @@ dependencies {
|
|
|
101
101
|
implementation "com.facebook.react:react-android"
|
|
102
102
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
103
103
|
implementation 'com.google.code.gson:gson:2.8.6'
|
|
104
|
-
//
|
|
105
|
-
implementation
|
|
106
|
-
// implementation 'com.customerglu:CustomerGluLibrary:3.1.2'
|
|
104
|
+
// For local testing: implementation project(':CustomerGluLibrary')
|
|
105
|
+
implementation 'com.customerglu:CustomerGluLibrary:4.1.2'
|
|
107
106
|
|
|
108
107
|
}
|
|
109
108
|
|
package/ios/IosBannerView.mm
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
[self addSubview:self->_bannerView];
|
|
54
54
|
self->_bannerView.frame = self.bounds;
|
|
55
55
|
self->_bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
56
|
+
self.clipsToBounds = NO;
|
|
56
57
|
self->_bannerInitialized = YES;
|
|
57
58
|
[self setNeedsLayout];
|
|
58
59
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@customerglu/react-native-customerglu",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "CustomerGlu React Native
|
|
3
|
+
"version": "4.1.2",
|
|
4
|
+
"description": "CustomerGlu React Native SDK \u2014 in-app gamification, rewards, and engagement campaigns for iOS and Android.",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
7
7
|
"module": "./lib/module/index.js",
|
|
@@ -48,7 +48,17 @@
|
|
|
48
48
|
"keywords": [
|
|
49
49
|
"react-native",
|
|
50
50
|
"ios",
|
|
51
|
-
"android"
|
|
51
|
+
"android",
|
|
52
|
+
"gamification",
|
|
53
|
+
"rewards",
|
|
54
|
+
"engagement",
|
|
55
|
+
"campaigns",
|
|
56
|
+
"in-app",
|
|
57
|
+
"customerglu",
|
|
58
|
+
"sdk",
|
|
59
|
+
"banners",
|
|
60
|
+
"nudges",
|
|
61
|
+
"entry-points"
|
|
52
62
|
],
|
|
53
63
|
"repository": {
|
|
54
64
|
"type": "git",
|