setupad-prebid-react-native 0.1.3

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 (66) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +325 -0
  3. package/VeonPrebidReactNative.podspec +59 -0
  4. package/android/build.gradle +90 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +4 -0
  7. package/android/src/main/java/com/setupadprebidreactnative/VeonPrebidReactNativeModule.kt +130 -0
  8. package/android/src/main/java/com/setupadprebidreactnative/VeonPrebidReactNativePackage.kt +20 -0
  9. package/android/src/main/java/com/setupadprebidreactnative/VeonPrebidReactNativeView.kt +425 -0
  10. package/android/src/main/java/com/setupadprebidreactnative/VeonPrebidReactNativeViewManager.kt +186 -0
  11. package/ios/RCTFabricComponentsPlugins.h +12 -0
  12. package/ios/VeonPrebidReactNative-Bridging-Header.h +9 -0
  13. package/ios/VeonPrebidReactNativeModule.m +17 -0
  14. package/ios/VeonPrebidReactNativeModule.swift +108 -0
  15. package/ios/VeonPrebidReactNativeView+Delegates.swift +217 -0
  16. package/ios/VeonPrebidReactNativeView.h +5 -0
  17. package/ios/VeonPrebidReactNativeView.swift +381 -0
  18. package/ios/VeonPrebidReactNativeViewComponentView.h +13 -0
  19. package/ios/VeonPrebidReactNativeViewComponentView.mm +166 -0
  20. package/ios/VeonPrebidReactNativeViewManager.m +49 -0
  21. package/ios/VeonPrebidReactNativeViewManager.swift +105 -0
  22. package/lib/module/CodegenTypes.d.js +2 -0
  23. package/lib/module/CodegenTypes.d.js.map +1 -0
  24. package/lib/module/Commands.js +14 -0
  25. package/lib/module/Commands.js.map +1 -0
  26. package/lib/module/VeonPrebidAd.js +112 -0
  27. package/lib/module/VeonPrebidAd.js.map +1 -0
  28. package/lib/module/VeonPrebidModule.js +132 -0
  29. package/lib/module/VeonPrebidModule.js.map +1 -0
  30. package/lib/module/VeonPrebidReactNativeViewNativeComponent.ts +50 -0
  31. package/lib/module/VeonPrebidView.js +14 -0
  32. package/lib/module/VeonPrebidView.js.map +1 -0
  33. package/lib/module/index.js +8 -0
  34. package/lib/module/index.js.map +1 -0
  35. package/lib/module/package.json +1 -0
  36. package/lib/module/types.js +8 -0
  37. package/lib/module/types.js.map +1 -0
  38. package/lib/module/useVeonPrebidAd.js +154 -0
  39. package/lib/module/useVeonPrebidAd.js.map +1 -0
  40. package/lib/typescript/package.json +1 -0
  41. package/lib/typescript/src/Commands.d.ts +14 -0
  42. package/lib/typescript/src/Commands.d.ts.map +1 -0
  43. package/lib/typescript/src/VeonPrebidAd.d.ts +4 -0
  44. package/lib/typescript/src/VeonPrebidAd.d.ts.map +1 -0
  45. package/lib/typescript/src/VeonPrebidModule.d.ts +59 -0
  46. package/lib/typescript/src/VeonPrebidModule.d.ts.map +1 -0
  47. package/lib/typescript/src/VeonPrebidReactNativeViewNativeComponent.d.ts +40 -0
  48. package/lib/typescript/src/VeonPrebidReactNativeViewNativeComponent.d.ts.map +1 -0
  49. package/lib/typescript/src/VeonPrebidView.d.ts +5 -0
  50. package/lib/typescript/src/VeonPrebidView.d.ts.map +1 -0
  51. package/lib/typescript/src/index.d.ts +7 -0
  52. package/lib/typescript/src/index.d.ts.map +1 -0
  53. package/lib/typescript/src/types.d.ts +89 -0
  54. package/lib/typescript/src/types.d.ts.map +1 -0
  55. package/lib/typescript/src/useVeonPrebidAd.d.ts +52 -0
  56. package/lib/typescript/src/useVeonPrebidAd.d.ts.map +1 -0
  57. package/package.json +169 -0
  58. package/src/CodegenTypes.d.ts +16 -0
  59. package/src/Commands.ts +25 -0
  60. package/src/VeonPrebidAd.tsx +159 -0
  61. package/src/VeonPrebidModule.ts +159 -0
  62. package/src/VeonPrebidReactNativeViewNativeComponent.ts +50 -0
  63. package/src/VeonPrebidView.tsx +13 -0
  64. package/src/index.tsx +12 -0
  65. package/src/types.ts +64 -0
  66. package/src/useVeonPrebidAd.ts +156 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 jahonov
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # Veon Prebid React Native
2
+
3
+ A React Native plugin for integrating Veon Prebid SDK with Google Ad Manager (GAM). Supports banner, interstitial, and rewarded video ads with waterfall approach (Prebid → GAM fallback).
4
+
5
+ ## Features
6
+
7
+ ✅ **Banner Ads** - Standard and custom sizes
8
+ ✅ **Interstitial Ads** - Full-screen ads
9
+ ✅ **Rewarded Video Ads** - User-rewarded video ads
10
+ ✅ **Waterfall Approach** - Prebid first, GAM fallback
11
+ ✅ **Explicit Control** - Manual load/show/hide methods
12
+ ✅ **TypeScript Support** - Full type definitions
13
+ ✅ **React Hooks** - `useVeonPrebidAd` hook for easy integration
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install setupad-prebid-react-native
19
+ # or
20
+ yarn add setupad-prebid-react-native
21
+ ```
22
+
23
+ ### iOS Setup
24
+
25
+ 1. Add Google Ad Manager App ID to `Info.plist`:
26
+
27
+ ```xml
28
+ <key>GADApplicationIdentifier</key>
29
+ <string>ca-app-pub-################~##########</string>
30
+ ```
31
+
32
+ 2. Add SKAdNetworkItems (see [Google's documentation](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/quick-start#update_your_infoplist))
33
+
34
+ 3. Install pods:
35
+
36
+ ```bash
37
+ cd ios && pod install
38
+ ```
39
+
40
+ ### Android Setup
41
+
42
+ 1. Add Google Ad Manager App ID to `AndroidManifest.xml`:
43
+
44
+ ```xml
45
+ <application>
46
+ <meta-data
47
+ android:name="com.google.android.gms.ads.APPLICATION_ID"
48
+ android:value="ca-app-pub-################~##########"/>
49
+ </application>
50
+ ```
51
+
52
+ 2. Add JitPack repository to `android/build.gradle`:
53
+
54
+ ```gradle
55
+ allprojects {
56
+ repositories {
57
+ maven { url 'https://jitpack.io' }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ### 1. Initialize SDK
65
+
66
+ ```typescript
67
+ import { VeonPrebidSDK } from 'setupad-prebid-react-native';
68
+
69
+ // Initialize once at app startup
70
+ await VeonPrebidSDK.getInstance().initialize({
71
+ prebidHost: 'https://prebid.veonadx.com/openrtb2/auction',
72
+ configHost: 'https://config.veonadx.com',
73
+ accountId: 'YOUR_ACCOUNT_ID',
74
+ timeoutMillis: 3000,
75
+ pbsDebug: __DEV__,
76
+ });
77
+ ```
78
+
79
+ ### 2. Display Banner Ad
80
+
81
+ ```typescript
82
+ import React, { useRef } from 'react';
83
+ import { VeonPrebidAd, AdType, AdController } from 'setupad-prebid-react-native';
84
+
85
+ function BannerExample() {
86
+ const adRef = useRef<AdController>(null);
87
+
88
+ return (
89
+ <VeonPrebidAd
90
+ ref={adRef}
91
+ adType={AdType.BANNER}
92
+ configId="YOUR_CONFIG_ID"
93
+ adUnitId="/YOUR_NETWORK_ID/YOUR_AD_UNIT"
94
+ width={300}
95
+ height={250}
96
+ refreshInterval={60}
97
+ onAdLoaded={(data) => {
98
+ console.log('Banner loaded from', data.sdk);
99
+ adRef.current?.showBanner();
100
+ }}
101
+ onAdFailed={(error) => console.error('Banner failed:', error)}
102
+ />
103
+ );
104
+ }
105
+ ```
106
+
107
+ ### 3. Display Interstitial Ad
108
+
109
+ ```typescript
110
+ import React, { useRef, useEffect } from 'react';
111
+ import { VeonPrebidAd, AdType, AdController } from 'setupad-prebid-react-native';
112
+
113
+ function InterstitialExample() {
114
+ const adRef = useRef<AdController>(null);
115
+
116
+ useEffect(() => {
117
+ // Load interstitial on mount
118
+ adRef.current?.loadInterstitial();
119
+ }, []);
120
+
121
+ const showAd = () => {
122
+ adRef.current?.showInterstitial();
123
+ };
124
+
125
+ return (
126
+ <>
127
+ <VeonPrebidAd
128
+ ref={adRef}
129
+ adType={AdType.INTERSTITIAL}
130
+ configId="YOUR_CONFIG_ID"
131
+ adUnitId="/YOUR_NETWORK_ID/YOUR_AD_UNIT"
132
+ onAdLoaded={(data) => console.log('Interstitial loaded')}
133
+ onAdClosed={() => console.log('Interstitial closed')}
134
+ />
135
+ <Button title="Show Interstitial" onPress={showAd} />
136
+ </>
137
+ );
138
+ }
139
+ ```
140
+
141
+ ### 4. Using Hooks
142
+
143
+ ```typescript
144
+ import { useVeonPrebidAd, AdType } from 'setupad-prebid-react-native';
145
+
146
+ function HookExample() {
147
+ const { adRef, loadBanner, showBanner } = useVeonPrebidAd(
148
+ {
149
+ adType: AdType.BANNER,
150
+ configId: 'YOUR_CONFIG_ID',
151
+ adUnitId: '/YOUR_NETWORK_ID/YOUR_AD_UNIT',
152
+ width: 300,
153
+ height: 250,
154
+ },
155
+ {
156
+ onAdLoaded: (data) => {
157
+ console.log('Ad loaded:', data);
158
+ showBanner();
159
+ },
160
+ }
161
+ );
162
+
163
+ useEffect(() => {
164
+ loadBanner();
165
+ }, []);
166
+
167
+ return <VeonPrebidAd ref={adRef} />;
168
+ }
169
+ ```
170
+
171
+ ## API Reference
172
+
173
+ ### VeonPrebidSDK
174
+
175
+ Singleton class for SDK initialization.
176
+
177
+ #### Methods
178
+
179
+ **`initialize(config: PrebidConfig): Promise<string>`**
180
+ - Initialize Prebid SDK
181
+ - Should be called once at app startup
182
+
183
+ **`getSDKVersion(): Promise<string>`**
184
+ - Get SDK version
185
+
186
+ **`isSDKInitialized(): boolean`**
187
+ - Check if SDK is initialized
188
+
189
+ ### VeonPrebidAd Component
190
+
191
+ #### Props
192
+
193
+ | Prop | Type | Required | Description |
194
+ |------|------|----------|-------------|
195
+ | `adType` | `AdType` | ✅ | Ad type: `banner`, `interstitial`, or `rewardVideo` |
196
+ | `configId` | `string` | ✅ | Prebid config ID |
197
+ | `adUnitId` | `string` | ✅ | Google Ad Manager ad unit ID |
198
+ | `width` | `number` | For banners | Ad width in pixels |
199
+ | `height` | `number` | For banners | Ad height in pixels |
200
+ | `refreshInterval` | `number` | ❌ | Refresh interval (30-120 seconds, default: 30) |
201
+ | `onAdLoaded` | `function` | ❌ | Called when ad is loaded |
202
+ | `onAdDisplayed` | `function` | ❌ | Called when ad is displayed |
203
+ | `onAdFailed` | `function` | ❌ | Called when ad fails |
204
+ | `onAdClicked` | `function` | ❌ | Called when ad is clicked |
205
+ | `onAdClosed` | `function` | ❌ | Called when ad is closed |
206
+
207
+ #### Ref Methods (AdController)
208
+
209
+ ```typescript
210
+ interface AdController {
211
+ loadBanner(): void;
212
+ showBanner(): void;
213
+ hideBanner(): void;
214
+ loadInterstitial(): void;
215
+ showInterstitial(): void;
216
+ hideInterstitial(): void;
217
+ pauseAuction(): void;
218
+ resumeAuction(): void;
219
+ destroyAuction(): void;
220
+ }
221
+ ```
222
+
223
+ ### useVeonPrebidAd Hook
224
+
225
+ ```typescript
226
+ const {
227
+ adRef,
228
+ loadBanner,
229
+ showBanner,
230
+ hideBanner,
231
+ loadInterstitial,
232
+ showInterstitial,
233
+ hideInterstitial,
234
+ pauseAuction,
235
+ resumeAuction,
236
+ destroyAuction,
237
+ } = useVeonPrebidAd(config, eventListener);
238
+ ```
239
+
240
+ ## Types
241
+
242
+ ```typescript
243
+ enum AdType {
244
+ BANNER = 'banner',
245
+ INTERSTITIAL = 'interstitial',
246
+ REWARD_VIDEO = 'rewardVideo',
247
+ }
248
+
249
+ interface PrebidConfig {
250
+ prebidHost: string;
251
+ configHost: string;
252
+ accountId: string;
253
+ timeoutMillis?: number;
254
+ pbsDebug?: boolean;
255
+ }
256
+
257
+ interface AdEventData {
258
+ adId?: string;
259
+ sdk?: string; // 'PREBID' or 'GAM'
260
+ message?: string;
261
+ }
262
+ ```
263
+
264
+ ## Best Practices
265
+
266
+ ### Banner Ads
267
+ 1. Load banner: `adRef.current?.loadBanner()`
268
+ 2. Show when loaded: `onAdLoaded={() => adRef.current?.showBanner()}`
269
+ 3. Hide if needed: `adRef.current?.hideBanner()`
270
+
271
+ ### Interstitial Ads
272
+ 1. Load early: `useEffect(() => adRef.current?.loadInterstitial(), [])`
273
+ 2. Show on user action: `adRef.current?.showInterstitial()`
274
+ 3. Reload after close: `onAdClosed={() => adRef.current?.loadInterstitial()}`
275
+
276
+ ### Lifecycle Management
277
+ - Pause banner refresh when app goes background: `pauseAuction()`
278
+ - Resume when app comes foreground: `resumeAuction()`
279
+ - Destroy when unmounting: `destroyAuction()`
280
+
281
+ ## Troubleshooting
282
+
283
+ ### Android
284
+
285
+ **Issue:** Build fails with "Maven repository not found"
286
+ **Solution:** Add JitPack repository to `android/build.gradle`
287
+
288
+ **Issue:** Ads not showing
289
+ **Solution:** Check LogCat for "VeonPrebidView" logs
290
+
291
+ ### iOS
292
+
293
+ **Issue:** Build fails with "Module not found"
294
+ **Solution:** Run `cd ios && pod install`
295
+
296
+ **Issue:** Ads not showing
297
+ **Solution:** Check Xcode console for "LOG:" messages
298
+
299
+ ## Example App
300
+
301
+ See the `example/` directory for a complete working example with banner and interstitial ads.
302
+
303
+ ```bash
304
+ cd example
305
+ npm install
306
+ npm run ios
307
+ # or
308
+ npm run android
309
+ ```
310
+
311
+ ## Requirements
312
+
313
+ - React Native >= 0.70
314
+ - iOS >= 11.0
315
+ - Android minSdkVersion >= 21
316
+
317
+ ## License
318
+
319
+ MIT
320
+
321
+ ## Support
322
+
323
+ For issues and questions, please visit:
324
+ - GitHub Issues: [veonadtech/veon_prebid_react_native](https://github.com/veonadtech/veon_prebid_react_native/issues)
325
+ - Documentation: [docs.veonadx.com](https://docs.veonadx.com)
@@ -0,0 +1,59 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "VeonPrebidReactNative"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.description = <<-DESC
10
+ React Native bridge for Veon Prebid SDK
11
+ DESC
12
+ s.homepage = "https://github.com/veonadtech/veon-prebid-react-native"
13
+ s.license = "MIT"
14
+ s.authors = { "Veon" => "info@veon.com" }
15
+ s.platforms = { :ios => "12.0" }
16
+ s.source = { :git => "https://github.com/veonadtech/veon-prebid-react-native.git", :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
19
+
20
+ # Install all dependencies
21
+ s.dependency "React-Core"
22
+
23
+ # Fabric (New Architecture) dependencies
24
+ install_modules_dependencies(s)
25
+ s.dependency "Google-Mobile-Ads-SDK", "12.3.0"
26
+ s.dependency "VeonPrebidMobileGAMEventHandlers", "0.0.4"
27
+ s.dependency "VeonPrebidMobile", "0.0.4"
28
+
29
+ s.static_framework = true
30
+ s.swift_version = "5.0"
31
+
32
+ # When consumer uses `use_frameworks!`, headers are inside .framework bundles
33
+ # and need explicit search paths for React Native internal C++ headers
34
+ if ENV['USE_FRAMEWORKS']
35
+ s.pod_target_xcconfig = {
36
+ 'DEFINES_MODULE' => 'YES',
37
+ 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
38
+ 'HEADER_SEARCH_PATHS' => [
39
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers"',
40
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers"',
41
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-featureflags/React_featureflags.framework/Headers"',
42
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-rendererdebug/React_rendererdebug.framework/Headers"',
43
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-Fabric/React_Fabric.framework/Headers"',
44
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-FabricComponents/React_FabricComponents.framework/Headers"',
45
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers"',
46
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios"',
47
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core"',
48
+ '"$(PODS_CONFIGURATION_BUILD_DIR)/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core/platform/ios"',
49
+ '"$(PODS_ROOT)/DoubleConversion"',
50
+ '"$(PODS_ROOT)/RCT-Folly"',
51
+ ].join(' ')
52
+ }
53
+ else
54
+ s.pod_target_xcconfig = {
55
+ 'DEFINES_MODULE' => 'YES',
56
+ 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
57
+ }
58
+ end
59
+ end
@@ -0,0 +1,90 @@
1
+ buildscript {
2
+ ext.getExtOrDefault = {name ->
3
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['VeonPrebidReactNative_' + name]
4
+ }
5
+
6
+ repositories {
7
+ google()
8
+ mavenCentral()
9
+ }
10
+
11
+ dependencies {
12
+ classpath "com.android.tools.build:gradle:8.7.2"
13
+ // noinspection DifferentKotlinGradleVersion
14
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
+ }
16
+ }
17
+
18
+
19
+ apply plugin: "com.android.library"
20
+ apply plugin: "kotlin-android"
21
+
22
+ apply plugin: "com.facebook.react"
23
+
24
+ def getExtOrIntegerDefault(name) {
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["VeonPrebidReactNative_" + name]).toInteger()
26
+ }
27
+
28
+ android {
29
+ namespace "com.setupadprebidreactnative"
30
+
31
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
32
+
33
+ defaultConfig {
34
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
36
+ }
37
+
38
+ buildFeatures {
39
+ buildConfig true
40
+ }
41
+
42
+ buildTypes {
43
+ release {
44
+ minifyEnabled false
45
+ }
46
+ }
47
+
48
+ lintOptions {
49
+ disable "GradleCompatible"
50
+ }
51
+
52
+ compileOptions {
53
+ sourceCompatibility JavaVersion.VERSION_1_8
54
+ targetCompatibility JavaVersion.VERSION_1_8
55
+ }
56
+
57
+ sourceSets {
58
+ main {
59
+ java.srcDirs += [
60
+ "generated/java",
61
+ "generated/jni"
62
+ ]
63
+ }
64
+ }
65
+ }
66
+
67
+ repositories {
68
+ mavenCentral()
69
+ google()
70
+
71
+ // JitPack repository for Veon Prebid SDK
72
+ maven { url 'https://jitpack.io' }
73
+ }
74
+
75
+ def kotlin_version = getExtOrDefault("kotlinVersion")
76
+
77
+ dependencies {
78
+ // React Native
79
+ implementation "com.facebook.react:react-android"
80
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
81
+
82
+ // Google Mobile Ads (AdManager)
83
+ implementation 'com.google.android.gms:play-services-ads:22.2.0'
84
+
85
+ // Veon Prebid SDK
86
+ implementation 'com.github.veonadtech.prebid-android-sdk:core:0.1.1'
87
+ implementation 'com.github.veonadtech.prebid-android-sdk:eventhandlers:0.1.1'
88
+ implementation 'com.github.veonadtech.prebid-android-sdk:mobile:0.1.1'
89
+ implementation 'com.github.veonadtech.prebid-android-sdk:prebidorg:0.1.1'
90
+ }
@@ -0,0 +1,5 @@
1
+ VeonPrebidReactNative_kotlinVersion=2.0.21
2
+ VeonPrebidReactNative_minSdkVersion=21
3
+ VeonPrebidReactNative_targetSdkVersion=34
4
+ VeonPrebidReactNative_compileSdkVersion=35
5
+ VeonPrebidReactNative_ndkVersion=27.1.12297006
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.INTERNET" />
3
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
4
+ </manifest>
@@ -0,0 +1,130 @@
1
+ package com.setupadprebidreactnative
2
+
3
+ import android.app.Activity
4
+ import android.util.Log
5
+ import com.facebook.react.bridge.*
6
+ import com.facebook.react.modules.core.DeviceEventManagerModule
7
+ import com.google.android.gms.ads.MobileAds
8
+ import org.prebid.mobile.PrebidMobile
9
+ import org.prebid.mobile.api.data.InitializationStatus
10
+ import java.util.concurrent.CompletableFuture
11
+
12
+ /**
13
+ * Native module for initializing Prebid SDK and handling SDK-level operations
14
+ */
15
+ class VeonPrebidReactNativeModule(private val reactContext: ReactApplicationContext) :
16
+ ReactContextBaseJavaModule(reactContext) {
17
+
18
+ private val TAG = "VeonPrebidReactNative"
19
+ private val activityFuture = CompletableFuture<Activity>()
20
+
21
+ override fun getName(): String {
22
+ return "VeonPrebidReactNativeModule"
23
+ }
24
+
25
+ /**
26
+ * Initialize Prebid Mobile SDK
27
+ * @param prebidHost - Prebid server host URL
28
+ * @param configHost - Configuration host URL
29
+ * @param accountId - Prebid account ID
30
+ * @param timeoutMillis - Timeout in milliseconds for bid requests
31
+ * @param pbsDebug - Enable/disable debug mode
32
+ * @param promise - Promise to return initialization result
33
+ */
34
+ @ReactMethod
35
+ fun initializeSDK(
36
+ prebidHost: String,
37
+ configHost: String,
38
+ accountId: String,
39
+ timeoutMillis: Int,
40
+ pbsDebug: Boolean,
41
+ promise: Promise
42
+ ) {
43
+ try {
44
+ Log.d(TAG, "Initializing Prebid SDK")
45
+ Log.d(TAG, "Host: $prebidHost")
46
+ Log.d(TAG, "Config Host: $configHost")
47
+ Log.d(TAG, "Account ID: $accountId")
48
+ Log.d(TAG, "Timeout: $timeoutMillis ms")
49
+ Log.d(TAG, "Debug: $pbsDebug")
50
+
51
+ val activity = reactContext.currentActivity
52
+ if (activity == null) {
53
+ promise.reject("NO_ACTIVITY", "Activity is not available")
54
+ return
55
+ }
56
+
57
+ // Set Prebid account ID
58
+ PrebidMobile.setPrebidServerAccountId(accountId)
59
+
60
+ // Initialize SDK
61
+ PrebidMobile.initializeSdk(activity.applicationContext, prebidHost, configHost) { status ->
62
+ when (status) {
63
+ InitializationStatus.SUCCEEDED -> {
64
+ Log.d(TAG, "Prebid Mobile SDK initialized successfully!")
65
+ sendEvent("prebidSdkInitialized", "successfully")
66
+ promise.resolve("successfully")
67
+ }
68
+ InitializationStatus.SERVER_STATUS_WARNING -> {
69
+ val message = "Server status warning: ${status.description}"
70
+ Log.w(TAG, message)
71
+ sendEvent("prebidSdkInitialized", message)
72
+ promise.resolve(message)
73
+ }
74
+ else -> {
75
+ val errorMessage = "Initialization error: ${status.description}"
76
+ Log.e(TAG, errorMessage)
77
+ sendEvent("prebidSdkInitializeFailed", errorMessage)
78
+ promise.reject("INIT_FAILED", errorMessage)
79
+ }
80
+ }
81
+ }
82
+
83
+ // Set debug mode
84
+ PrebidMobile.setPbsDebug(pbsDebug)
85
+
86
+ // Check Google Mobile Ads compatibility
87
+ PrebidMobile.checkGoogleMobileAdsCompatibility(MobileAds.getVersion().toString())
88
+
89
+ // Set timeout
90
+ PrebidMobile.setTimeoutMillis(timeoutMillis)
91
+
92
+ // Enable geo location sharing
93
+ PrebidMobile.setShareGeoLocation(true)
94
+
95
+ } catch (e: Exception) {
96
+ Log.e(TAG, "Error initializing Prebid SDK: ${e.message}", e)
97
+ promise.reject("INIT_ERROR", "Failed to initialize SDK: ${e.message}", e)
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Get Prebid SDK version
103
+ */
104
+ @ReactMethod
105
+ fun getSDKVersion(promise: Promise) {
106
+ try {
107
+ val version = PrebidMobile.SDK_VERSION
108
+ promise.resolve(version)
109
+ } catch (e: Exception) {
110
+ promise.reject("VERSION_ERROR", "Failed to get SDK version: ${e.message}", e)
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Send event to JavaScript
116
+ */
117
+ private fun sendEvent(eventName: String, params: Any?) {
118
+ try {
119
+ reactContext
120
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
121
+ .emit(eventName, params)
122
+ } catch (e: Exception) {
123
+ Log.e(TAG, "Error sending event: ${e.message}", e)
124
+ }
125
+ }
126
+
127
+ companion object {
128
+ const val NAME = "VeonPrebidReactNativeModule"
129
+ }
130
+ }
@@ -0,0 +1,20 @@
1
+ package com.setupadprebidreactnative
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+ class VeonPrebidReactNativeViewPackage : ReactPackage {
9
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
10
+ return listOf(
11
+ VeonPrebidReactNativeViewManager(reactContext)
12
+ )
13
+ }
14
+
15
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
16
+ return listOf(
17
+ VeonPrebidReactNativeModule(reactContext)
18
+ )
19
+ }
20
+ }