cloudx-react-native 3.1.2 → 3.4.0

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.
Files changed (62) hide show
  1. package/README.md +40 -649
  2. package/android/build.gradle +1 -2
  3. package/android/src/main/java/com/cloudxreactnative/CloudXModuleImpl.kt +134 -27
  4. package/android/src/newarch/com/cloudxreactnative/CloudXModule.kt +5 -0
  5. package/android/src/oldarch/com/cloudxreactnative/CloudXModule.kt +23 -2
  6. package/cloudx-react-native.podspec +1 -1
  7. package/ios/CloudX.mm +215 -0
  8. package/lib/commonjs/CloudXBannerAd.js +4 -0
  9. package/lib/commonjs/CloudXBannerAd.js.map +1 -1
  10. package/lib/commonjs/CloudXInterstitialAd.js +4 -0
  11. package/lib/commonjs/CloudXInterstitialAd.js.map +1 -1
  12. package/lib/commonjs/CloudXMRECAd.js +4 -0
  13. package/lib/commonjs/CloudXMRECAd.js.map +1 -1
  14. package/lib/commonjs/CloudXRewardedAd.js +4 -0
  15. package/lib/commonjs/CloudXRewardedAd.js.map +1 -1
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/specs/NativeCloudX.js.map +1 -1
  18. package/lib/commonjs/types/ExtraParameters.js +2 -0
  19. package/lib/commonjs/types/ExtraParameters.js.map +1 -0
  20. package/lib/commonjs/version.js +1 -1
  21. package/lib/module/CloudXBannerAd.js +4 -0
  22. package/lib/module/CloudXBannerAd.js.map +1 -1
  23. package/lib/module/CloudXInterstitialAd.js +4 -0
  24. package/lib/module/CloudXInterstitialAd.js.map +1 -1
  25. package/lib/module/CloudXMRECAd.js +4 -0
  26. package/lib/module/CloudXMRECAd.js.map +1 -1
  27. package/lib/module/CloudXRewardedAd.js +4 -0
  28. package/lib/module/CloudXRewardedAd.js.map +1 -1
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/specs/NativeCloudX.js.map +1 -1
  31. package/lib/module/types/ExtraParameters.js +2 -0
  32. package/lib/module/types/ExtraParameters.js.map +1 -0
  33. package/lib/module/version.js +1 -1
  34. package/lib/typescript/src/CloudXBannerAd.d.ts.map +1 -1
  35. package/lib/typescript/src/CloudXInterstitialAd.d.ts.map +1 -1
  36. package/lib/typescript/src/CloudXMRECAd.d.ts.map +1 -1
  37. package/lib/typescript/src/CloudXRewardedAd.d.ts.map +1 -1
  38. package/lib/typescript/src/index.d.ts +1 -1
  39. package/lib/typescript/src/index.d.ts.map +1 -1
  40. package/lib/typescript/src/specs/NativeCloudX.d.ts +5 -0
  41. package/lib/typescript/src/specs/NativeCloudX.d.ts.map +1 -1
  42. package/lib/typescript/src/types/ExtraParameters.d.ts +7 -0
  43. package/lib/typescript/src/types/ExtraParameters.d.ts.map +1 -0
  44. package/lib/typescript/src/types/FullscreenAd.d.ts +3 -0
  45. package/lib/typescript/src/types/FullscreenAd.d.ts.map +1 -1
  46. package/lib/typescript/src/types/ViewAd.d.ts +2 -0
  47. package/lib/typescript/src/types/ViewAd.d.ts.map +1 -1
  48. package/lib/typescript/src/types/index.d.ts +1 -0
  49. package/lib/typescript/src/types/index.d.ts.map +1 -1
  50. package/lib/typescript/src/version.d.ts +1 -1
  51. package/package.json +3 -1
  52. package/src/CloudXBannerAd.ts +6 -0
  53. package/src/CloudXInterstitialAd.ts +6 -0
  54. package/src/CloudXMRECAd.ts +6 -0
  55. package/src/CloudXRewardedAd.ts +6 -0
  56. package/src/index.ts +2 -0
  57. package/src/specs/NativeCloudX.ts +5 -0
  58. package/src/types/ExtraParameters.ts +11 -0
  59. package/src/types/FullscreenAd.ts +4 -0
  60. package/src/types/ViewAd.ts +2 -0
  61. package/src/types/index.ts +1 -0
  62. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -1,677 +1,68 @@
1
1
  # CloudX React Native SDK
2
2
 
3
- [![npm](https://img.shields.io/npm/v/cloudx-react-native)](https://www.npmjs.com/package/cloudx-react-native)
3
+ React Native wrapper for the CloudX SDK.
4
4
 
5
- The CloudX React Native SDK enables monetization of your React Native apps with banner, MREC, interstitial, and rewarded ads on iOS and Android. It supports both the New Architecture (Fabric) and the legacy architecture (Paper).
5
+ Full integration docs live in the public docs site. Keep setup guides, ad-format examples, native adapter setup, and public release notes there instead of duplicating them in this repository.
6
6
 
7
- ## Features
7
+ ## Public Documentation
8
8
 
9
- - **Cross-Platform**: Full iOS and Android support
10
- - **Dual Architecture**: Works on both Fabric (New Architecture) and Paper (Legacy)
11
- - **All Ad Formats**: Banner, MREC, Interstitial, and Rewarded ads
12
- - **Programmatic Ad APIs**: Overlay APIs for banner and MREC, plus fullscreen formats
13
- - **React Hooks**: Declarative hooks for fullscreen and banner ad lifecycles
14
- - **Privacy Compliance**: IAB privacy handled automatically via CMP shared storage, plus manual `setHasUserConsent` / `setDoNotSell` overrides
15
- - **App Tracking Transparency**: Built-in ATT support for iOS 14+
16
- - **Type Safety**: Full TypeScript definitions with CloudX-prefixed namespace
9
+ - [React Native integration guide](https://docs.cloudx.io/en/react-native/integration)
10
+ - Ad format guides:
11
+ - [Banner and MREC ads](https://docs.cloudx.io/en/react-native/ad-formats/banner-mrec)
12
+ - [Interstitial ads](https://docs.cloudx.io/en/react-native/ad-formats/interstitial)
13
+ - [Rewarded ads](https://docs.cloudx.io/en/react-native/ad-formats/rewarded)
14
+ - [React Native changelog](https://docs.cloudx.io/en/react-native/changelog)
17
15
 
18
- ### Native SDK Versions
16
+ When customer-facing behavior changes, update the docs repo directly and link the docs PR from the SDK or release PR.
19
17
 
20
- | Plugin | iOS (`CloudXCore`) | Android (`io.cloudx:sdk`) |
21
- |--------|-------------------|---------------------------|
22
- | 3.1.2 | 3.1.0 | 3.1.0 |
23
- | 2.2.3 | 2.2.3 | 2.2.3 |
18
+ ## Repository Layout
24
19
 
25
- ## Installation
20
+ - `src/` - JavaScript and TypeScript API surface consumed by React Native apps.
21
+ - `ios/` - iOS native bridge over `CloudXCore`.
22
+ - `android/` - Android native bridge over `io.cloudx:sdk`.
23
+ - `demo-app/` - React Native demo app for manual and automated validation.
24
+ - `cloudx-react-native.podspec` - CocoaPods package metadata.
25
+ - `RELEASE.md` - Internal release process.
26
26
 
27
- Requires React Native 0.70+, React 18.0+, iOS 13.0+, and Android API 23+.
27
+ ## Development
28
28
 
29
- ```bash
30
- npm install cloudx-react-native
31
- ```
32
-
33
- ### iOS Setup
34
-
35
- Add ad network adapter pods to your `ios/Podfile`:
36
-
37
- ```ruby
38
- target 'YourApp' do
39
- # ... existing config ...
40
-
41
- # CloudX ad network adapters (add as needed)
42
- pod 'CloudXMetaAdapter', '~> 3.1.0'
43
- pod 'CloudXVungleAdapter', '~> 3.1.0'
44
- pod 'CloudXInMobiAdapter', '~> 3.1.0'
45
- pod 'CloudXMintegralAdapter', '~> 3.1.0'
46
- pod 'CloudXUnityAdsAdapter', '~> 3.1.0'
47
- pod 'CloudXRenderer', '~> 3.1.0'
48
- end
49
- ```
50
-
51
- Then install pods:
29
+ Install dependencies:
52
30
 
53
31
  ```bash
54
- cd ios && pod install
55
- ```
56
-
57
- > **Note:** The `CloudXCore` pod is automatically included as a dependency of the `cloudx-react-native` npm package. You only need to add the adapter pods you want.
58
-
59
- #### App Transport Security
60
-
61
- If your ads use HTTP URLs, add the following to your `Info.plist`:
62
-
63
- ```xml
64
- <key>NSAppTransportSecurity</key>
65
- <dict>
66
- <key>NSAllowsArbitraryLoads</key>
67
- <true/>
68
- </dict>
69
- ```
70
-
71
- ### Android Setup
72
-
73
- Add CloudX SDK and adapter dependencies to your `android/app/build.gradle`:
74
-
75
- ```kotlin
76
- dependencies {
77
- // CloudX Android SDK
78
- implementation "io.cloudx:sdk:3.1.0"
79
-
80
- // Adapters for ad networks (add as needed)
81
- implementation "io.cloudx:adapter-meta:3.1.0"
82
- implementation "io.cloudx:adapter-vungle:3.1.0"
83
- implementation "io.cloudx:adapter-inmobi:3.1.0"
84
- implementation "io.cloudx:adapter-mintegral:3.1.0"
85
- implementation "io.cloudx:adapter-unityads:3.1.0"
86
-
87
- // Required by the native SDK 3.1.0 when using the Meta adapter.
88
- implementation "com.facebook.android:audience-network-sdk:6.21.0"
89
- }
90
- ```
91
-
92
- > **Note:** At least one adapter is required for the SDK to serve ads.
93
-
94
- If you integrate the Mintegral adapter, also declare its Maven repository in `android/build.gradle` (Mintegral is not on Maven Central):
95
-
96
- ```kotlin
97
- allprojects {
98
- repositories {
99
- maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" }
100
- }
101
- }
32
+ npm install
102
33
  ```
103
34
 
104
- ## Initialization
105
-
106
- Initialize the SDK before loading any ads:
107
-
108
- ```typescript
109
- import { CloudX, CloudXLogLevel } from 'cloudx-react-native';
110
-
111
- // Optional: enable verbose logging (development only)
112
- CloudX.setMinLogLevel(CloudXLogLevel.VERBOSE);
113
-
114
- // Initialize with your app key
115
- const result = await CloudX.initialize('YOUR_APP_KEY');
116
- if (result.success) {
117
- console.log('CloudX initialized');
118
- } else {
119
- console.error('CloudX init failed:', result.message);
120
- }
121
- ```
122
-
123
- ### Initialization API
124
-
125
- | Method | Returns | Description |
126
- |--------|---------|-------------|
127
- | `CloudX.initialize(appKey)` | `Promise<CloudXInitializationResult>` | Initialize the SDK with your app key |
128
- | `CloudX.isInitialized()` | `Promise<boolean>` | Check if the SDK has been initialized |
129
- | `CloudX.getVersion()` | `Promise<string>` | Get the native SDK version string |
130
- | `CloudX.isTablet()` | `Promise<boolean>` | Check if the device is a tablet |
131
-
132
- The `CloudXInitializationResult` contains:
133
- - `success: boolean` — whether initialization succeeded
134
- - `message?: string` — additional details on failure
135
-
136
- ## Ad Integration
137
-
138
- ### Banner Ads (Programmatic Overlay)
139
-
140
- Banners overlay your content at a fixed screen position:
141
-
142
- ```typescript
143
- import { CloudXBannerAd, CloudXAdPosition } from 'cloudx-react-native';
144
-
145
- const AD_UNIT_ID = 'home_banner';
146
-
147
- // Set up event listeners
148
- CloudXBannerAd.addAdLoadedEventListener((adInfo) => {
149
- console.log('Banner loaded from', adInfo.networkName);
150
- });
151
- CloudXBannerAd.addAdLoadFailedEventListener((error) => {
152
- console.log('Banner failed:', error.code, error.message);
153
- });
154
- CloudXBannerAd.addAdRevenuePaidListener((adInfo) => {
155
- console.log('Banner revenue:', adInfo.revenue);
156
- });
157
-
158
- // Create and show
159
- CloudXBannerAd.createAd(AD_UNIT_ID, CloudXAdPosition.BOTTOM_CENTER);
160
- CloudXBannerAd.showAd(AD_UNIT_ID);
161
-
162
- // Hide / destroy when done
163
- CloudXBannerAd.hideAd(AD_UNIT_ID);
164
- CloudXBannerAd.destroyAd(AD_UNIT_ID);
165
- ```
166
-
167
- Auto-refresh is enabled by default. To control it manually:
168
-
169
- ```typescript
170
- CloudXBannerAd.stopAutoRefresh(AD_UNIT_ID);
171
- CloudXBannerAd.startAutoRefresh(AD_UNIT_ID);
172
- ```
173
-
174
- #### Full Banner API
175
-
176
- | Method | Description |
177
- |--------|-------------|
178
- | `createAd(adUnitId, position)` | Create a banner at the given `CloudXAdPosition` |
179
- | `createAdWithOffsets(adUnitId, position, xOffset, yOffset)` | Create with pixel offsets from the position anchor |
180
- | `showAd(adUnitId)` | Show the banner |
181
- | `hideAd(adUnitId)` | Hide the banner (preserves the ad) |
182
- | `destroyAd(adUnitId)` | Destroy the banner and release resources |
183
- | `updatePosition(adUnitId, position)` | Move to a new `CloudXAdPosition` |
184
- | `updateOffsets(adUnitId, xOffset, yOffset)` | Update pixel offsets |
185
- | `setBackgroundColor(adUnitId, hexColor)` | Set banner background color (e.g., `"#000000"`) |
186
- | `setPlacement(adUnitId, placement)` | Set placement name for reporting |
187
- | `setCustomData(adUnitId, customData)` | Set custom data string |
188
- | `startAutoRefresh(adUnitId)` | Resume auto-refresh |
189
- | `stopAutoRefresh(adUnitId)` | Pause auto-refresh |
190
-
191
- #### Banner Events
192
-
193
- | Method | Callback Parameter |
194
- |--------|--------------------|
195
- | `addAdLoadedEventListener(fn)` | `CloudXAdInfo` |
196
- | `addAdLoadFailedEventListener(fn)` | `CloudXAdLoadFailedInfo` |
197
- | `addAdClickedEventListener(fn)` | `CloudXAdInfo` |
198
- | `addAdExpandedEventListener(fn)` | `CloudXAdInfo` |
199
- | `addAdCollapsedEventListener(fn)` | `CloudXAdInfo` |
200
- | `addAdRevenuePaidListener(fn)` | `CloudXAdInfo` |
201
-
202
- Each `add*` listener has a corresponding `remove*` method (e.g., `removeAdLoadedEventListener()`).
203
-
204
- ### MREC Ads (Programmatic Overlay)
205
-
206
- MRECs work identically to banners but with a 300x250 size:
207
-
208
- ```typescript
209
- import { CloudXMRECAd, CloudXAdPosition } from 'cloudx-react-native';
210
-
211
- const AD_UNIT_ID = 'home_mrec';
212
-
213
- CloudXMRECAd.addAdLoadedEventListener((adInfo) => {
214
- console.log('MREC loaded from', adInfo.networkName);
215
- });
216
-
217
- CloudXMRECAd.createAd(AD_UNIT_ID, CloudXAdPosition.CENTERED);
218
- CloudXMRECAd.showAd(AD_UNIT_ID);
219
-
220
- // Destroy when done
221
- CloudXMRECAd.destroyAd(AD_UNIT_ID);
222
- ```
223
-
224
- The MREC API surface is identical to Banner — all the same methods and events are available on `CloudXMRECAd`, including `createAdWithOffsets`, `updatePosition`, `updateOffsets`, `setBackgroundColor`, `setPlacement`, `setCustomData`, auto-refresh control, and all event listeners.
225
-
226
- ### Interstitial Ads
227
-
228
- Full-screen ads shown at natural transition points.
229
-
230
- ```typescript
231
- import { CloudXInterstitialAd } from 'cloudx-react-native';
232
-
233
- const AD_UNIT_ID = 'level_complete';
234
-
235
- // Set up event listeners
236
- CloudXInterstitialAd.addAdLoadedEventListener((adInfo) => {
237
- console.log('Interstitial loaded');
238
- });
239
- CloudXInterstitialAd.addAdLoadFailedEventListener((error) => {
240
- console.log('Interstitial load failed:', error.code, error.message);
241
- });
242
- CloudXInterstitialAd.addAdDisplayedEventListener((adInfo) => {
243
- console.log('Interstitial displayed');
244
- });
245
- CloudXInterstitialAd.addAdFailedToDisplayEventListener((error) => {
246
- console.log('Interstitial display failed:', error.code, error.message);
247
- });
248
- CloudXInterstitialAd.addAdHiddenEventListener((adInfo) => {
249
- // Reload for next use
250
- CloudXInterstitialAd.loadAd(AD_UNIT_ID);
251
- });
252
- CloudXInterstitialAd.addAdRevenuePaidListener((adInfo) => {
253
- console.log('Revenue:', adInfo.revenue);
254
- });
255
-
256
- // Load
257
- CloudXInterstitialAd.loadAd(AD_UNIT_ID);
258
-
259
- // Show when ready (with optional placement and custom data)
260
- const isReady = await CloudXInterstitialAd.isAdReady(AD_UNIT_ID);
261
- if (isReady) {
262
- CloudXInterstitialAd.showAd(AD_UNIT_ID);
263
- // or with placement/custom data:
264
- // CloudXInterstitialAd.showAd(AD_UNIT_ID, 'level_end', 'custom_data');
265
- }
266
-
267
- // Destroy when done
268
- CloudXInterstitialAd.destroyAd(AD_UNIT_ID);
269
- ```
270
-
271
- #### Interstitial API
272
-
273
- | Method | Description |
274
- |--------|-------------|
275
- | `loadAd(adUnitId)` | Start loading an interstitial |
276
- | `isAdReady(adUnitId)` | Returns `Promise<boolean>` — whether an ad is ready to show |
277
- | `showAd(adUnitId, placement?, customData?)` | Show the loaded interstitial |
278
- | `destroyAd(adUnitId)` | Destroy the interstitial and release resources |
279
-
280
- #### Interstitial Events
281
-
282
- | Method | Callback Parameter |
283
- |--------|--------------------|
284
- | `addAdLoadedEventListener(fn)` | `CloudXAdInfo` |
285
- | `addAdLoadFailedEventListener(fn)` | `CloudXAdLoadFailedInfo` |
286
- | `addAdDisplayedEventListener(fn)` | `CloudXAdInfo` |
287
- | `addAdFailedToDisplayEventListener(fn)` | `CloudXAdDisplayFailedInfo` |
288
- | `addAdClickedEventListener(fn)` | `CloudXAdInfo` |
289
- | `addAdHiddenEventListener(fn)` | `CloudXAdInfo` |
290
- | `addAdRevenuePaidListener(fn)` | `CloudXAdInfo` |
291
-
292
- ### Rewarded Ads
293
-
294
- Full-screen ads that grant users a reward upon completion.
295
-
296
- ```typescript
297
- import { CloudXRewardedAd } from 'cloudx-react-native';
298
-
299
- const AD_UNIT_ID = 'rewarded_coins';
300
-
301
- // Set up event listeners
302
- CloudXRewardedAd.addAdLoadedEventListener((adInfo) => {
303
- console.log('Rewarded loaded');
304
- });
305
- CloudXRewardedAd.addAdLoadFailedEventListener((error) => {
306
- console.log('Rewarded load failed:', error.code, error.message);
307
- });
308
- CloudXRewardedAd.addAdDisplayedEventListener((adInfo) => {
309
- console.log('Rewarded displayed');
310
- });
311
- CloudXRewardedAd.addAdFailedToDisplayEventListener((error) => {
312
- console.log('Rewarded display failed:', error.code, error.message);
313
- });
314
- CloudXRewardedAd.addAdReceivedRewardEventListener((rewardInfo) => {
315
- console.log(`Earned ${rewardInfo.rewardAmount} ${rewardInfo.rewardLabel}`);
316
- });
317
- CloudXRewardedAd.addAdHiddenEventListener((adInfo) => {
318
- // Reload for next use
319
- CloudXRewardedAd.loadAd(AD_UNIT_ID);
320
- });
321
- CloudXRewardedAd.addAdRevenuePaidListener((adInfo) => {
322
- console.log('Revenue:', adInfo.revenue);
323
- });
324
-
325
- // Load
326
- CloudXRewardedAd.loadAd(AD_UNIT_ID);
327
-
328
- // Show when ready (with optional placement and custom data)
329
- const isReady = await CloudXRewardedAd.isAdReady(AD_UNIT_ID);
330
- if (isReady) {
331
- CloudXRewardedAd.showAd(AD_UNIT_ID);
332
- }
333
-
334
- // Destroy when done
335
- CloudXRewardedAd.destroyAd(AD_UNIT_ID);
336
- ```
337
-
338
- #### Rewarded API
339
-
340
- | Method | Description |
341
- |--------|-------------|
342
- | `loadAd(adUnitId)` | Start loading a rewarded ad |
343
- | `isAdReady(adUnitId)` | Returns `Promise<boolean>` — whether an ad is ready to show |
344
- | `showAd(adUnitId, placement?, customData?)` | Show the loaded rewarded ad |
345
- | `destroyAd(adUnitId)` | Destroy the rewarded ad and release resources |
346
-
347
- #### Rewarded Events
348
-
349
- | Method | Callback Parameter |
350
- |--------|--------------------|
351
- | `addAdLoadedEventListener(fn)` | `CloudXAdInfo` |
352
- | `addAdLoadFailedEventListener(fn)` | `CloudXAdLoadFailedInfo` |
353
- | `addAdDisplayedEventListener(fn)` | `CloudXAdInfo` |
354
- | `addAdFailedToDisplayEventListener(fn)` | `CloudXAdDisplayFailedInfo` |
355
- | `addAdClickedEventListener(fn)` | `CloudXAdInfo` |
356
- | `addAdHiddenEventListener(fn)` | `CloudXAdInfo` |
357
- | `addAdReceivedRewardEventListener(fn)` | `CloudXAdRewardInfo` |
358
- | `addAdRevenuePaidListener(fn)` | `CloudXAdInfo` |
359
-
360
- ## React Hooks
361
-
362
- The SDK provides React hooks for declarative ad management that handle event subscriptions and cleanup automatically.
363
-
364
- ### useCloudXInterstitial
365
-
366
- ```typescript
367
- import { useCloudXInterstitial } from 'cloudx-react-native';
368
-
369
- function GameScreen() {
370
- const { isLoaded, isLoading, error, load, show, destroy } =
371
- useCloudXInterstitial('level_complete');
372
-
373
- useEffect(() => {
374
- load();
375
- }, [load]);
376
-
377
- return (
378
- <Button
379
- title={isLoading ? 'Loading...' : 'Show Ad'}
380
- onPress={() => show()}
381
- disabled={!isLoaded}
382
- />
383
- );
384
- }
385
- ```
35
+ Build generated package outputs:
386
36
 
387
- Returns `CloudXInterstitialHookResult`:
388
- - `isLoaded: boolean` — ad is ready to show
389
- - `isLoading: boolean` — load in progress
390
- - `error: string | null` — last error message
391
- - `load()` — start loading
392
- - `show(placement?, customData?)` — show the loaded ad
393
- - `destroy()` — destroy and reset state
394
-
395
- ### useCloudXRewarded
396
-
397
- ```typescript
398
- import { useCloudXRewarded } from 'cloudx-react-native';
399
-
400
- function RewardScreen() {
401
- const { isLoaded, isLoading, error, rewardEarned, load, show } =
402
- useCloudXRewarded('rewarded_coins');
403
-
404
- useEffect(() => {
405
- load();
406
- }, [load]);
407
-
408
- useEffect(() => {
409
- if (rewardEarned) {
410
- grantCoinsToUser();
411
- }
412
- }, [rewardEarned]);
413
-
414
- return (
415
- <Button
416
- title="Watch Ad for Coins"
417
- onPress={() => show()}
418
- disabled={!isLoaded}
419
- />
420
- );
421
- }
422
- ```
423
-
424
- Returns `CloudXRewardedHookResult`:
425
- - `isLoaded: boolean` — ad is ready to show
426
- - `isLoading: boolean` — load in progress
427
- - `error: string | null` — last error message
428
- - `rewardEarned: boolean` — user completed the ad and earned a reward
429
- - `load()` — start loading
430
- - `show(placement?, customData?)` — show the loaded ad
431
- - `destroy()` — destroy and reset state
432
-
433
- ### useCloudXBanner
434
-
435
- ```typescript
436
- import { useCloudXBanner, CloudXBannerAd, CloudXAdPosition } from 'cloudx-react-native';
437
-
438
- function HomeScreen() {
439
- const { isLoaded, error } = useCloudXBanner('home_banner');
440
-
441
- useEffect(() => {
442
- CloudXBannerAd.createAd('home_banner', CloudXAdPosition.BOTTOM_CENTER);
443
- CloudXBannerAd.showAd('home_banner');
444
- return () => CloudXBannerAd.destroyAd('home_banner');
445
- }, []);
446
-
447
- return <Text>{isLoaded ? 'Banner showing' : 'Loading banner...'}</Text>;
448
- }
449
- ```
450
-
451
- Returns `CloudXBannerHookResult`:
452
- - `isLoaded: boolean` — banner has loaded an ad
453
- - `error: string | null` — last error message
454
-
455
- ## Types Reference
456
-
457
- ### CloudXAdInfo
458
-
459
- Received by most ad event callbacks:
460
-
461
- ```typescript
462
- type CloudXAdInfo = {
463
- adUnitId: string;
464
- adFormat: string; // "BANNER", "MREC", "INTERSTITIAL", "REWARDED"
465
- networkName: string;
466
- networkPlacement?: string | null;
467
- placement?: string | null;
468
- revenue: number; // USD
469
- };
470
- ```
471
-
472
- ### CloudXAdLoadFailedInfo
473
-
474
- Received by `addAdLoadFailedEventListener`:
475
-
476
- ```typescript
477
- type CloudXAdLoadFailedInfo = {
478
- adUnitId: string;
479
- code: CloudXErrorCode;
480
- message?: string | null;
481
- };
482
- ```
483
-
484
- ### CloudXAdDisplayFailedInfo
485
-
486
- Received by `addAdFailedToDisplayEventListener`:
487
-
488
- ```typescript
489
- type CloudXAdDisplayFailedInfo = CloudXAdInfo & {
490
- code: CloudXErrorCode;
491
- message?: string | null;
492
- };
493
- ```
494
-
495
- ### CloudXAdRewardInfo
496
-
497
- Received by `addAdReceivedRewardEventListener`:
498
-
499
- ```typescript
500
- type CloudXAdRewardInfo = CloudXAdInfo & {
501
- rewardLabel?: string | null;
502
- rewardAmount: number;
503
- };
504
- ```
505
-
506
- ### CloudXAdPosition
507
-
508
- Position constants for programmatic banner and MREC placement:
509
-
510
- ```typescript
511
- enum CloudXAdPosition {
512
- TOP_LEFT, TOP_CENTER, TOP_RIGHT,
513
- CENTER_LEFT, CENTERED, CENTER_RIGHT,
514
- BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT,
515
- }
516
- ```
517
-
518
- ## Advanced Features
519
-
520
- ### Error Handling
521
-
522
- All error callbacks receive an object with `code` and `message` properties:
523
-
524
- | Range | Category | Common Codes |
525
- |-------|----------|--------------|
526
- | 0 | General | `internalError` |
527
- | 100-199 | Network | `networkError`, `networkTimeout`, `networkNoConnection` |
528
- | 200-299 | Initialization | `notInitialized`, `sdkDisabled`, `invalidAppKey` |
529
- | 300-399 | Ad Loading | `noFill`, `invalidAdUnit`, `adsDisabled` |
530
- | 400-499 | Display | `adNotReady`, `adAlreadyShowing` |
531
- | 600-699 | Adapter | `adapterNoFill`, `adapterTimeout` |
532
-
533
- See `CloudXErrorCode` export for the full list of error codes.
534
-
535
- ### Revenue Tracking
536
-
537
- All ad formats provide revenue callbacks. The `CloudXAdInfo` object includes `revenue` (USD) and `networkName`:
538
-
539
- ```typescript
540
- CloudXInterstitialAd.addAdRevenuePaidListener((adInfo) => {
541
- trackRevenue(adInfo.revenue, adInfo.networkName, adInfo.adUnitId);
542
- });
543
- ```
544
-
545
- ### User Targeting
546
-
547
- ```typescript
548
- import { CloudX } from 'cloudx-react-native';
549
-
550
- // Set hashed user ID
551
- CloudX.setHashedUserID('hashed-user-id');
552
-
553
- // Set custom key-value pairs
554
- CloudX.setUserKeyValue('age_group', '25-34');
555
- CloudX.setAppKeyValue('app_version', '1.0.0');
556
-
557
- // Clear all custom key-values
558
- CloudX.clearAllKeyValues();
559
- ```
560
-
561
- ### Manual Privacy Overrides
562
-
563
- In most cases, IAB privacy signals (TCF, US Privacy String) are read automatically from shared `NSUserDefaults` / `SharedPreferences` written by your CMP. Use the manual APIs only when you need to override a CMP-provided value or when you don't use a CMP:
564
-
565
- ```typescript
566
- import { CloudX } from 'cloudx-react-native';
567
-
568
- // GDPR: user has granted consent
569
- CloudX.setHasUserConsent(true);
570
-
571
- // CCPA / US Privacy: user opted out of sale
572
- CloudX.setDoNotSell(true);
573
-
574
- // Clear a previously set override (fall back to CMP signal)
575
- CloudX.setHasUserConsent(null);
576
- CloudX.setDoNotSell(null);
577
- ```
578
-
579
- Call these before `CloudX.initialize()` so the value is available before the first auction.
580
-
581
- ### App Tracking Transparency (iOS)
582
-
583
- ```typescript
584
- import { requestTrackingAuthorization, getTrackingAuthorizationStatus, CloudXATTStatus } from 'cloudx-react-native';
585
-
586
- const status = await requestTrackingAuthorization();
587
- if (status === CloudXATTStatus.AUTHORIZED) {
588
- console.log('Tracking authorized');
589
- }
37
+ ```bash
38
+ npm run prepare
590
39
  ```
591
40
 
592
- > **Note:** Call `requestTrackingAuthorization()` before `CloudX.initialize()` for best ad targeting results.
593
-
594
- ATT status values: `AUTHORIZED`, `DENIED`, `RESTRICTED`, `NOT_DETERMINED`, `NOT_REQUIRED`.
595
-
596
- On Android or iOS < 14, `requestTrackingAuthorization()` returns `NOT_REQUIRED`.
597
-
598
- ### Test Mode
599
-
600
- Test mode is **server-controlled** via device whitelisting:
601
-
602
- 1. Initialize the SDK with verbose logging enabled
603
- 2. Find your device advertising ID in the console logs
604
- 3. Add the device to your whitelist on the CloudX dashboard
41
+ Run library checks:
605
42
 
606
- ### Debug Logging
607
-
608
- ```typescript
609
- import { CloudX, CloudXLogLevel } from 'cloudx-react-native';
610
-
611
- // Enable verbose logging (call before initialize)
612
- CloudX.setMinLogLevel(CloudXLogLevel.VERBOSE);
613
-
614
- // Available levels: VERBOSE, DEBUG, INFO, WARN, ERROR, NONE
43
+ ```bash
44
+ npm run typescript
45
+ npm run lint
615
46
  ```
616
47
 
617
- ### Visual Debugging
618
-
619
- Enable visual debugging overlays to see ad unit boundaries and network info:
48
+ Run the demo app:
620
49
 
621
- ```typescript
622
- CloudX.setVisualDebuggingEnabled(true);
50
+ ```bash
51
+ cd demo-app
52
+ npm install
53
+ npm run ios
54
+ npm run android
623
55
  ```
624
56
 
625
- ## Platform Support
626
-
627
- | Platform | Status | Minimum Version |
628
- |----------|--------|-----------------|
629
- | iOS | Supported | iOS 13.0+ |
630
- | Android | Supported | API 23+ |
631
-
632
- ### Requirements
633
-
634
- - React Native 0.70+
635
- - React 18.0+
636
- - TypeScript 4.5+ (recommended)
637
- - Xcode 14.0+ / CocoaPods (iOS)
638
- - Gradle 8.0+ / Kotlin 1.8+ (Android)
639
-
640
- ### Native SDK Versions (3.1.0)
641
-
642
- | Platform | Dependency | Version |
643
- |----------|-----------|---------|
644
- | iOS | CloudXCore | ~> 3.1.0 |
645
- | Android | io.cloudx:sdk | 3.1.0 |
57
+ Install demo iOS pods:
646
58
 
647
- ## Troubleshooting
648
-
649
- ### React Native 0.84.0 — TurboModuleRegistry crash
650
-
651
- React Native 0.84.0 has a known issue where `TurboModuleRegistry.getEnforcing(...)` fails with:
652
-
653
- > `TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary.`
654
-
655
- This is a React Native framework bug, not a CloudX SDK issue. It manifests as a red screen crash on app launch:
656
-
657
- ```
658
- TurboModuleRegistry.getEnforcing(...):
659
- 'PlatformConstants' could not be found. Verify
660
- that a module by this name is registered in
661
- the native binary.
59
+ ```bash
60
+ cd demo-app/ios
61
+ pod install
662
62
  ```
663
63
 
664
- **Workaround:** Use React Native 0.83.x or wait for the fix in a later 0.84.x patch release. The CloudX SDK is fully compatible with RN 0.70 through 0.83.
665
-
666
- ## Documentation
667
-
668
- - **[Integration Guide](https://docs.cloudx.io/en/react-native/integration)**: Complete integration documentation
669
- - **[Changelog](https://docs.cloudx.io/en/react-native/changelog)**: Release history
670
-
671
- ## Support
672
-
673
- For support, contact mobile@cloudx.io
64
+ ## Releases
674
65
 
675
- ## License
66
+ Follow [RELEASE.md](RELEASE.md) for npm releases, native dependency updates, QA gates, and post-release validation.
676
67
 
677
- This project is licensed under the Elastic License 2.0 — see the [LICENSE](LICENSE) file for details.
68
+ Public integration docs and release notes belong in the docs repo.