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
@@ -0,0 +1,108 @@
1
+ import Foundation
2
+ import React
3
+ import PrebidMobile
4
+ import GoogleMobileAds
5
+
6
+ @objc(VeonPrebidReactNativeModule)
7
+ class VeonPrebidReactNativeModule: RCTEventEmitter {
8
+
9
+ private var isInitialized = false
10
+
11
+ override init() {
12
+ super.init()
13
+ }
14
+
15
+ @objc
16
+ override static func requiresMainQueueSetup() -> Bool {
17
+ return true
18
+ }
19
+
20
+ override func supportedEvents() -> [String]! {
21
+ return ["prebidSdkInitialized", "prebidSdkInitializeFailed"]
22
+ }
23
+
24
+ // MARK: - SDK Initialization
25
+
26
+ @objc
27
+ func initializeSDK(
28
+ _ prebidHost: String,
29
+ configHost: String,
30
+ accountId: String,
31
+ timeoutMillis: NSNumber,
32
+ pbsDebug: Bool,
33
+ resolve: @escaping RCTPromiseResolveBlock,
34
+ reject: @escaping RCTPromiseRejectBlock
35
+ ) {
36
+ // Prevent multiple initializations
37
+ if isInitialized {
38
+ resolve("already initialized")
39
+ return
40
+ }
41
+
42
+ DispatchQueue.main.async { [weak self] in
43
+ guard let self = self else {
44
+ reject("INIT_ERROR", "Module deallocated", nil)
45
+ return
46
+ }
47
+
48
+ print("Initializing Veon Prebid SDK...")
49
+ print("Host: \(prebidHost)")
50
+ print("Config Host: \(configHost)")
51
+ print("Account ID: \(accountId)")
52
+ print("Timeout: \(timeoutMillis) ms")
53
+ print("Debug: \(pbsDebug)")
54
+
55
+ // Set Prebid account ID
56
+ Prebid.shared.prebidServerAccountId = accountId
57
+
58
+ // Set timeout (must be set before initialization)
59
+ Prebid.shared.timeoutMillis = timeoutMillis.intValue
60
+
61
+ // Set debug mode
62
+ Prebid.shared.pbsDebug = pbsDebug
63
+
64
+ // Enable geo location sharing
65
+ Prebid.shared.shareGeoLocation = true
66
+
67
+ // Set sourceapp and itunesID for SKAdNetwork support
68
+ if let bundleIdentifier = Bundle.main.bundleIdentifier {
69
+ Targeting.shared.sourceapp = bundleIdentifier
70
+ }
71
+ // Optionally set iTunes ID if available
72
+ // Targeting.shared.itunesID = "your-app-store-id"
73
+
74
+ do {
75
+ try Prebid.initializeSDK(
76
+ serverURL: prebidHost,
77
+ gadMobileAdsVersion: string(for: MobileAds.shared.versionNumber)
78
+ ) { status, error in
79
+ print("Prebid Mobile SDK initialized successfully!")
80
+ self.isInitialized = true
81
+ self.sendEvent(withName: "prebidSdkInitialized", body: "successfully")
82
+ resolve("successfully") // Return success
83
+ }
84
+ } catch {
85
+ let errorMessage = "Initialization failed"
86
+ print(errorMessage)
87
+ self.sendEvent(withName: "prebidSdkInitializeFailed", body: errorMessage)
88
+ reject("INIT_FAILED", errorMessage, nil)
89
+ }
90
+
91
+ }
92
+ }
93
+
94
+ // MARK: - SDK Version
95
+
96
+ @objc
97
+ func getSDKVersion(
98
+ _ resolve: @escaping RCTPromiseResolveBlock,
99
+ reject: @escaping RCTPromiseRejectBlock
100
+ ) {
101
+ do {
102
+ let version = Prebid.shared.version
103
+ resolve(version)
104
+ } catch {
105
+ reject("VERSION_ERROR", "Failed to get SDK version: \(error.localizedDescription)", error)
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,217 @@
1
+ import UIKit
2
+ import GoogleMobileAds
3
+ import PrebidMobile
4
+
5
+ // MARK: - InterstitialAdUnitDelegate
6
+
7
+ extension VeonPrebidReactNativeView: InterstitialAdUnitDelegate {
8
+
9
+ func interstitialDidReceiveAd(_ interstitial: InterstitialRenderingAdUnit) {
10
+ NSLog("VeonPrebid iOS: Interstitial ad loaded")
11
+ onAdLoaded?([
12
+ "configId": adParameters.configId ?? "",
13
+ "adUnitId": adParameters.adUnitId ?? "",
14
+ "sdkType": "prebid"
15
+ ])
16
+ }
17
+
18
+ func interstitial(_ interstitial: InterstitialRenderingAdUnit, didFailToReceiveAdWithError error: Error?) {
19
+ let errorMsg = error?.localizedDescription ?? "Unknown error"
20
+ NSLog("VeonPrebid iOS: Interstitial failed to load - \(errorMsg)")
21
+ onAdFailed?([
22
+ "configId": adParameters.configId ?? "",
23
+ "adUnitId": adParameters.adUnitId ?? "",
24
+ "error": errorMsg,
25
+ "sdkType": "prebid"
26
+ ])
27
+ }
28
+
29
+ func interstitialWillLeaveApplication(_ interstitial: InterstitialRenderingAdUnit) {
30
+ NSLog("VeonPrebid iOS: Interstitial will leave application")
31
+ onAdClicked?([
32
+ "configId": adParameters.configId ?? "",
33
+ "adUnitId": adParameters.adUnitId ?? "",
34
+ "sdkType": "prebid"
35
+ ])
36
+ }
37
+
38
+ func interstitialDidClickAd(_ interstitial: InterstitialRenderingAdUnit) {
39
+ NSLog("VeonPrebid iOS: Interstitial clicked")
40
+ onAdClicked?([
41
+ "configId": adParameters.configId ?? "",
42
+ "adUnitId": adParameters.adUnitId ?? "",
43
+ "sdkType": "prebid"
44
+ ])
45
+ }
46
+
47
+ func interstitialDidCloseAd(_ interstitial: InterstitialRenderingAdUnit) {
48
+ NSLog("VeonPrebid iOS: Interstitial closed")
49
+ onAdClosed?([
50
+ "configId": adParameters.configId ?? "",
51
+ "adUnitId": adParameters.adUnitId ?? "",
52
+ "sdkType": "prebid"
53
+ ])
54
+ }
55
+
56
+ func interstitialWillPresentAd(_ interstitial: InterstitialRenderingAdUnit) {
57
+ NSLog("VeonPrebid iOS: Interstitial displayed")
58
+ onAdDisplayed?([
59
+ "configId": adParameters.configId ?? "",
60
+ "adUnitId": adParameters.adUnitId ?? "",
61
+ "sdkType": "prebid"
62
+ ])
63
+ }
64
+ }
65
+
66
+ // MARK: - BannerViewDelegate
67
+
68
+ extension VeonPrebidReactNativeView: PrebidMobile.BannerViewDelegate {
69
+
70
+ func bannerViewPresentationController() -> UIViewController? {
71
+ return getRootViewController()
72
+ }
73
+
74
+ func bannerView(_ bannerView: PrebidMobile.BannerView, didReceiveAdWithAdSize adSize: CGSize) {
75
+ NSLog("VeonPrebid iOS: Prebid banner loaded successfully")
76
+ onAdLoaded?([
77
+ "configId": bannerView.configID,
78
+ "adUnitId": adParameters.adUnitId ?? "",
79
+ "sdkType": "prebid"
80
+ ])
81
+ }
82
+
83
+ func bannerView(_ bannerView: PrebidMobile.BannerView, didFailToReceiveAdWith error: Error) {
84
+ let errorMsg = error.localizedDescription
85
+ NSLog("VeonPrebid iOS: Prebid banner failed to load - \(errorMsg)")
86
+ onAdFailed?([
87
+ "configId": bannerView.configID,
88
+ "adUnitId": adParameters.adUnitId ?? "",
89
+ "error": errorMsg,
90
+ "sdkType": "prebid"
91
+ ])
92
+ }
93
+
94
+ func bannerViewDidRecordImpression(_ bannerView: PrebidMobile.BannerView) {
95
+ NSLog("VeonPrebid iOS: Banner recorded impression")
96
+ }
97
+
98
+ func bannerViewWillLeaveApplication(_ bannerView: PrebidMobile.BannerView) {
99
+ NSLog("VeonPrebid iOS: Banner will leave application")
100
+ onAdClicked?([
101
+ "configId": bannerView.configID,
102
+ "adUnitId": adParameters.adUnitId ?? "",
103
+ "sdkType": "prebid"
104
+ ])
105
+ }
106
+
107
+ func bannerViewWillPresentModal(_ bannerView: PrebidMobile.BannerView) {
108
+ onAdDisplayed?([
109
+ "configId": bannerView.configID,
110
+ "adUnitId": adParameters.adUnitId ?? "",
111
+ "sdkType": "prebid"
112
+ ])
113
+ }
114
+ }
115
+
116
+ // MARK: - RewardedAdUnitDelegate
117
+
118
+ extension VeonPrebidReactNativeView: RewardedAdUnitDelegate {
119
+
120
+ func rewardedAdDidReceiveAd(_ rewardedAd: RewardedAdUnit) {
121
+ NSLog("VeonPrebid iOS: Rewarded ad received")
122
+ onAdLoaded?([
123
+ "configId": adParameters.configId ?? "",
124
+ "adUnitId": adParameters.adUnitId ?? "",
125
+ "sdkType": "prebid"
126
+ ])
127
+
128
+ if rewardedAd.isReady {
129
+ rewardedAd.show(from: getRootViewController())
130
+ }
131
+ }
132
+
133
+ func rewardedAd(_ rewardedAd: RewardedAdUnit, didFailToReceiveAdWithError error: Error?) {
134
+ let errorMsg = error?.localizedDescription ?? "Unknown error"
135
+ NSLog("VeonPrebid iOS: Rewarded ad failed to load - \(errorMsg)")
136
+ onAdFailed?([
137
+ "configId": adParameters.configId ?? "",
138
+ "adUnitId": adParameters.adUnitId ?? "",
139
+ "error": errorMsg,
140
+ "sdkType": "prebid"
141
+ ])
142
+ }
143
+
144
+ func rewardedAdUserDidEarnReward(_ rewardedAd: RewardedAdUnit, reward: PrebidReward) {
145
+ let rewardType = reward.type ?? ""
146
+ let rewardCount = reward.count ?? 0
147
+ NSLog("VeonPrebid iOS: User earned reward - type: \(rewardType), count: \(rewardCount)")
148
+ }
149
+
150
+ func rewardedAdWillPresentAd(_ rewardedAd: RewardedAdUnit) {
151
+ NSLog("VeonPrebid iOS: Rewarded ad will present")
152
+ onAdDisplayed?([
153
+ "configId": adParameters.configId ?? "",
154
+ "adUnitId": adParameters.adUnitId ?? "",
155
+ "sdkType": "prebid"
156
+ ])
157
+ }
158
+
159
+ func rewardedAdDidDismissAd(_ rewardedAd: RewardedAdUnit) {
160
+ NSLog("VeonPrebid iOS: Rewarded ad dismissed")
161
+ onAdClosed?([
162
+ "configId": adParameters.configId ?? "",
163
+ "adUnitId": adParameters.adUnitId ?? "",
164
+ "sdkType": "prebid"
165
+ ])
166
+ }
167
+
168
+ func rewardedAdDidClickAd(_ rewardedAd: RewardedAdUnit) {
169
+ NSLog("VeonPrebid iOS: Rewarded ad clicked")
170
+ onAdClicked?([
171
+ "configId": adParameters.configId ?? "",
172
+ "adUnitId": adParameters.adUnitId ?? "",
173
+ "sdkType": "prebid"
174
+ ])
175
+ }
176
+
177
+ func rewardedAdWillLeaveApplication(_ rewardedAd: RewardedAdUnit) {
178
+ NSLog("VeonPrebid iOS: Rewarded ad will leave application")
179
+ onAdClicked?([
180
+ "configId": adParameters.configId ?? "",
181
+ "adUnitId": adParameters.adUnitId ?? "",
182
+ "sdkType": "prebid"
183
+ ])
184
+ }
185
+ }
186
+
187
+ // MARK: - GADBannerViewDelegate
188
+
189
+ extension VeonPrebidReactNativeView: GoogleMobileAds.BannerViewDelegate {
190
+
191
+ func bannerViewDidReceiveAd(_ bannerView: GoogleMobileAds.BannerView) {
192
+ NSLog("VeonPrebid iOS: GAM banner loaded successfully")
193
+ onAdLoaded?([
194
+ "configId": adParameters.configId ?? "",
195
+ "adUnitId": bannerView.adUnitID ?? "",
196
+ "sdkType": "gam"
197
+ ])
198
+ }
199
+
200
+ func bannerView(_ bannerView: GoogleMobileAds.BannerView,
201
+ didFailToReceiveAdWithError error: Error) {
202
+ let errorMsg = error.localizedDescription
203
+ NSLog("VeonPrebid iOS: GAM banner failed to load - \(errorMsg)")
204
+ onAdFailed?([
205
+ "configId": adParameters.configId ?? "",
206
+ "adUnitId": bannerView.adUnitID ?? "",
207
+ "error": errorMsg,
208
+ "sdkType": "gam"
209
+ ])
210
+
211
+ // Fallback to Prebid ad when GAM fails
212
+ gamBanner = nil
213
+ loadPrebidBanner()
214
+ }
215
+ }
216
+
217
+ // End of VeonPrebidReactNativeView+Delegates.swift
@@ -0,0 +1,5 @@
1
+ #import <React/RCTViewManager.h>
2
+ #import <UIKit/UIKit.h>
3
+
4
+ // Forward declaration for Swift class
5
+ @class VeonPrebidReactNativeView;