@thealteroffice/react-native-adgeist 0.0.19 → 0.0.22
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/Adgeist.podspec +1 -1
- package/README.md +70 -521
- package/android/build.gradle +6 -3
- package/android/generated/java/com/adgeist/NativeAdgeistSpec.java +11 -11
- package/android/generated/java/com/facebook/react/viewmanagers/HTML5AdNativeComponentManagerDelegate.java +55 -0
- package/android/generated/java/com/facebook/react/viewmanagers/HTML5AdNativeComponentManagerInterface.java +24 -0
- package/android/generated/jni/RNAdgeistSpec-generated.cpp +12 -12
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/EventEmitters.cpp +60 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/EventEmitters.h +49 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/Props.cpp +28 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/Props.h +52 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI-generated.cpp +14 -22
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI.h +36 -36
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ShadowNodes.h +32 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNAdgeistSpec/States.h +29 -0
- package/android/src/main/java/com/adgeist/AdgeistPackage.kt +8 -7
- package/android/src/main/java/com/adgeist/components/HTML5AdViewManagerImpl.kt +125 -0
- package/android/src/main/java/com/adgeist/modules/AdgeistImpl.kt +114 -0
- package/android/src/main/java/com/adgeist/utils/CreativeExtensions.kt +151 -0
- package/android/src/newarch/java/com/Adgeist.kt +119 -0
- package/android/src/newarch/java/com/HTML5AdViewManager.kt +77 -0
- package/android/src/oldarch/java/com/Adgeist.kt +132 -0
- package/android/src/oldarch/java/com/HTML5AdViewManager.kt +63 -0
- package/ios/Adgeist-Bridging-Header.h +3 -0
- package/ios/Adgeist.h +1 -1
- package/ios/Adgeist.mm +154 -38
- package/ios/AdgeistImpl.swift +188 -53
- package/ios/NativeHTML5AdManager.h +9 -0
- package/ios/NativeHTML5AdManager.mm +178 -0
- package/ios/NativeHTML5AdView.swift +136 -0
- package/ios/generated/RNAdgeistSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNAdgeistSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNAdgeistSpec/EventEmitters.cpp +60 -0
- package/ios/generated/RNAdgeistSpec/EventEmitters.h +49 -0
- package/ios/generated/RNAdgeistSpec/Props.cpp +28 -0
- package/ios/generated/RNAdgeistSpec/Props.h +52 -0
- package/ios/generated/RNAdgeistSpec/RCTComponentViewHelpers.h +65 -0
- package/ios/generated/RNAdgeistSpec/RNAdgeistSpec-generated.mm +17 -17
- package/ios/generated/RNAdgeistSpec/RNAdgeistSpec.h +17 -25
- package/ios/generated/RNAdgeistSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNAdgeistSpec/ShadowNodes.h +32 -0
- package/ios/generated/RNAdgeistSpec/States.cpp +16 -0
- package/ios/generated/RNAdgeistSpec/States.h +29 -0
- package/ios/generated/RNAdgeistSpecJSI-generated.cpp +14 -22
- package/ios/generated/RNAdgeistSpecJSI.h +36 -36
- package/lib/module/cdpclient/index.js +1 -25
- package/lib/module/cdpclient/index.js.map +1 -1
- package/lib/module/components/HTML5AdView.js +128 -0
- package/lib/module/components/HTML5AdView.js.map +1 -0
- package/lib/module/components/{BannerAd.js → deprecated/BannerAdView.js} +50 -79
- package/lib/module/components/deprecated/BannerAdView.js.map +1 -0
- package/lib/module/components/{ConsentModal.js → deprecated/ConsentModal.js} +2 -2
- package/lib/module/components/deprecated/ConsentModal.js.map +1 -0
- package/lib/module/constants.js +14 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/{components → providers}/AdgeistProvider.js +10 -35
- package/lib/module/providers/AdgeistProvider.js.map +1 -0
- package/lib/module/specs/HTML5AdNativeComponent.ts +46 -0
- package/lib/module/specs/NativeAdgeist.js.map +1 -0
- package/lib/module/types/AdSize.js +2 -0
- package/lib/module/types/AdSize.js.map +1 -0
- package/lib/module/types/CPMAdResponse.js +2 -0
- package/lib/module/types/CPMAdResponse.js.map +1 -0
- package/lib/module/types/FixedAdResponse.js +2 -0
- package/lib/module/types/FixedAdResponse.js.map +1 -0
- package/lib/module/types/HTML5AdNativeComponentProps.js +4 -0
- package/lib/module/types/HTML5AdNativeComponentProps.js.map +1 -0
- package/lib/module/types/Provider.js +2 -0
- package/lib/module/types/Provider.js.map +1 -0
- package/lib/typescript/src/cdpclient/index.d.ts +1 -21
- package/lib/typescript/src/cdpclient/index.d.ts.map +1 -1
- package/lib/typescript/src/components/HTML5AdView.d.ts +3 -0
- package/lib/typescript/src/components/HTML5AdView.d.ts.map +1 -0
- package/lib/typescript/src/components/deprecated/BannerAdView.d.ts +17 -0
- package/lib/typescript/src/components/deprecated/BannerAdView.d.ts.map +1 -0
- package/lib/typescript/src/components/deprecated/ConsentModal.d.ts.map +1 -0
- package/lib/typescript/src/constants.d.ts +10 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/providers/AdgeistProvider.d.ts +9 -0
- package/lib/typescript/src/providers/AdgeistProvider.d.ts.map +1 -0
- package/lib/typescript/src/specs/HTML5AdNativeComponent.d.ts +29 -0
- package/lib/typescript/src/specs/HTML5AdNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAdgeist.d.ts +28 -0
- package/lib/typescript/src/specs/NativeAdgeist.d.ts.map +1 -0
- package/lib/typescript/src/types/AdSize.d.ts +5 -0
- package/lib/typescript/src/types/AdSize.d.ts.map +1 -0
- package/lib/typescript/src/types/CPMAdResponse.d.ts +25 -0
- package/lib/typescript/src/types/CPMAdResponse.d.ts.map +1 -0
- package/lib/typescript/src/types/FixedAdResponse.d.ts +50 -0
- package/lib/typescript/src/types/FixedAdResponse.d.ts.map +1 -0
- package/lib/typescript/src/types/HTML5AdNativeComponentProps.d.ts +24 -0
- package/lib/typescript/src/types/HTML5AdNativeComponentProps.d.ts.map +1 -0
- package/lib/typescript/src/types/Provider.d.ts +16 -0
- package/lib/typescript/src/types/Provider.d.ts.map +1 -0
- package/package.json +8 -3
- package/plugin/build/android/withRNAdgeistMainApplication.d.ts +3 -0
- package/plugin/build/android/withRNAdgeistMainApplication.js +65 -0
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +25 -0
- package/plugin/build/ios/withRNAdgeistAppDelegate.d.ts +4 -0
- package/plugin/build/ios/withRNAdgeistAppDelegate.js +66 -0
- package/react-native.config.js +1 -1
- package/src/cdpclient/index.ts +1 -21
- package/src/components/HTML5AdView.tsx +161 -0
- package/src/components/{BannerAd.tsx → deprecated/BannerAdView.tsx} +80 -115
- package/src/components/{ConsentModal.tsx → deprecated/ConsentModal.tsx} +2 -2
- package/src/constants.ts +8 -0
- package/src/index.tsx +4 -2
- package/src/{components → providers}/AdgeistProvider.tsx +26 -60
- package/src/specs/HTML5AdNativeComponent.ts +46 -0
- package/src/{NativeAdgeist.ts → specs/NativeAdgeist.ts} +26 -25
- package/src/types/AdSize.ts +4 -0
- package/src/types/CPMAdResponse.ts +26 -0
- package/src/types/FixedAdResponse.ts +51 -0
- package/src/types/HTML5AdNativeComponentProps.ts +28 -0
- package/src/types/Provider.ts +16 -0
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/adgeist/implementation/AdgeistModuleImpl.kt +0 -252
- package/android/src/newarch/java/com/AdgeistModule.kt +0 -135
- package/android/src/oldarch/java/com/AdgeistModule.kt +0 -148
- package/ios/adgeist-Bridging-Header.h +0 -1
- package/lib/module/NativeAdgeist.js.map +0 -1
- package/lib/module/components/AdgeistProvider.js.map +0 -1
- package/lib/module/components/BannerAd.js.map +0 -1
- package/lib/module/components/ConsentModal.js.map +0 -1
- package/lib/typescript/src/NativeAdgeist.d.ts +0 -28
- package/lib/typescript/src/NativeAdgeist.d.ts.map +0 -1
- package/lib/typescript/src/components/AdgeistProvider.d.ts +0 -50
- package/lib/typescript/src/components/AdgeistProvider.d.ts.map +0 -1
- package/lib/typescript/src/components/BannerAd.d.ts +0 -64
- package/lib/typescript/src/components/BannerAd.d.ts.map +0 -1
- package/lib/typescript/src/components/ConsentModal.d.ts.map +0 -1
- /package/lib/module/{NativeAdgeist.js → specs/NativeAdgeist.js} +0 -0
- /package/lib/typescript/src/components/{ConsentModal.d.ts → deprecated/ConsentModal.d.ts} +0 -0
package/ios/AdgeistImpl.swift
CHANGED
|
@@ -8,25 +8,35 @@ import React
|
|
|
8
8
|
private var postCreativeAnalytic: CreativeAnalytics?
|
|
9
9
|
|
|
10
10
|
@objc public func initializeSdk(
|
|
11
|
-
|
|
11
|
+
customBidRequestBackendDomain: String?,
|
|
12
|
+
customPackageOrBundleID: String?,
|
|
13
|
+
customAdgeistAppID: String?,
|
|
12
14
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
13
15
|
rejecter: @escaping RCTPromiseRejectBlock
|
|
14
16
|
) {
|
|
15
17
|
do {
|
|
16
|
-
adgeistInstance = AdgeistCore.initialize(
|
|
18
|
+
adgeistInstance = AdgeistCore.initialize(customBidRequestBackendDomain: customBidRequestBackendDomain,
|
|
19
|
+
customPackageOrBundleID: customPackageOrBundleID,
|
|
20
|
+
customAdgeistAppID: customAdgeistAppID)
|
|
17
21
|
getAd = adgeistInstance?.getCreative()
|
|
18
22
|
postCreativeAnalytic = adgeistInstance?.postCreativeAnalytics()
|
|
19
|
-
resolver("SDK initialized with domain: \(
|
|
23
|
+
resolver("SDK initialized with domain: \(customBidRequestBackendDomain ?? "default")")
|
|
20
24
|
} catch {
|
|
21
25
|
rejecter("INIT_FAILED", "SDK initialization failed", error)
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
@objc public func destroySdk(
|
|
30
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
31
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
32
|
+
) {
|
|
33
|
+
AdgeistCore.destroy()
|
|
34
|
+
resolver("SDK destroyed")
|
|
35
|
+
}
|
|
36
|
+
|
|
25
37
|
@objc public func fetchCreative(
|
|
26
|
-
apiKey: String,
|
|
27
|
-
origin: String,
|
|
28
38
|
adSpaceId: String,
|
|
29
|
-
|
|
39
|
+
buyType: String,
|
|
30
40
|
isTestEnvironment: Bool,
|
|
31
41
|
resolver: @escaping RCTPromiseResolveBlock,
|
|
32
42
|
rejecter: @escaping RCTPromiseRejectBlock
|
|
@@ -37,64 +47,28 @@ import React
|
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
getAd.fetchCreative(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
adSpaceId: adSpaceId,
|
|
43
|
-
companyId: publisherId,
|
|
50
|
+
adUnitID: adSpaceId,
|
|
51
|
+
buyType: buyType,
|
|
44
52
|
isTestEnvironment: isTestEnvironment
|
|
45
53
|
) { creativeData in
|
|
46
54
|
if let creativeData = creativeData {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
var result: [String: Any] = [:]
|
|
56
|
+
|
|
57
|
+
// Use Mirror to reflect the object's properties
|
|
58
|
+
let mirror = Mirror(reflecting: creativeData)
|
|
59
|
+
for child in mirror.children {
|
|
60
|
+
if let label = child.label {
|
|
61
|
+
result[label] = child.value
|
|
54
62
|
}
|
|
55
|
-
} catch {
|
|
56
|
-
rejecter("JSON_ERROR", "Failed to encode ad data", error)
|
|
57
63
|
}
|
|
64
|
+
|
|
65
|
+
resolver(result)
|
|
58
66
|
} else {
|
|
59
67
|
rejecter("NO_AD", "Ad data not available", nil)
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
@objc public func sendCreativeAnalytic(
|
|
65
|
-
campaignId: String,
|
|
66
|
-
adSpaceId: String,
|
|
67
|
-
publisherId: String,
|
|
68
|
-
eventType: String,
|
|
69
|
-
origin: String,
|
|
70
|
-
apiKey: String,
|
|
71
|
-
bidId: String,
|
|
72
|
-
isTestEnvironment: Bool,
|
|
73
|
-
resolver: @escaping RCTPromiseResolveBlock,
|
|
74
|
-
rejecter: @escaping RCTPromiseRejectBlock
|
|
75
|
-
) {
|
|
76
|
-
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
77
|
-
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
postCreativeAnalytic.sendTrackingData(
|
|
82
|
-
campaignId: campaignId,
|
|
83
|
-
adSpaceId: adSpaceId,
|
|
84
|
-
publisherId: publisherId,
|
|
85
|
-
eventType: eventType,
|
|
86
|
-
origin: origin,
|
|
87
|
-
apiKey: apiKey,
|
|
88
|
-
bidId: bidId,
|
|
89
|
-
isTestEnvironment: isTestEnvironment
|
|
90
|
-
) { response in
|
|
91
|
-
if let response = response {
|
|
92
|
-
resolver(response)
|
|
93
|
-
} else {
|
|
94
|
-
rejecter("NO_AD", "Couldn't find the campaign to update analytics", nil)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
72
|
|
|
99
73
|
@objc public func setUserDetails(_ userDetailsDict: [String: Any]) {
|
|
100
74
|
let filtered = userDetailsDict.compactMapValues { value -> Any? in
|
|
@@ -143,6 +117,167 @@ import React
|
|
|
143
117
|
adgeistInstance?.logEvent(event)
|
|
144
118
|
}
|
|
145
119
|
|
|
120
|
+
public func sendCreativeAnalytics(
|
|
121
|
+
analyticsRequest: AnalyticsRequestDEPRECATED,
|
|
122
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
123
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
124
|
+
) {
|
|
125
|
+
postCreativeAnalytic?.sendTrackingData(analyticsRequestDEPRECATED: analyticsRequest)
|
|
126
|
+
resolver("Event sent successfully")
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@objc public func trackImpression(
|
|
130
|
+
campaignId: String,
|
|
131
|
+
adSpaceId: String,
|
|
132
|
+
bidId: String,
|
|
133
|
+
bidMeta: String,
|
|
134
|
+
buyType: String,
|
|
135
|
+
isTestEnvironment: Bool,
|
|
136
|
+
renderTime: Float,
|
|
137
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
138
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
139
|
+
) {
|
|
140
|
+
var builder = AnalyticsRequestDEPRECATED.AnalyticsRequestBuilderDEPRECATED(adUnitID: adSpaceId, isTestMode: isTestEnvironment)
|
|
141
|
+
|
|
142
|
+
let upperBuyType = buyType.uppercased()
|
|
143
|
+
if upperBuyType == "CPM" {
|
|
144
|
+
builder = builder.buildCPMRequest(campaignID: campaignId, bidID: bidId)
|
|
145
|
+
} else if upperBuyType == "FIXED" {
|
|
146
|
+
builder = builder.buildFIXEDRequest(metaData: bidMeta)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let request = builder.trackImpression(renderTime: renderTime).build()
|
|
150
|
+
sendCreativeAnalytics(analyticsRequest: request, resolver: resolver, rejecter: rejecter)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@objc public func trackView(
|
|
154
|
+
campaignId: String,
|
|
155
|
+
adSpaceId: String,
|
|
156
|
+
bidId: String,
|
|
157
|
+
bidMeta: String,
|
|
158
|
+
buyType: String,
|
|
159
|
+
isTestEnvironment: Bool,
|
|
160
|
+
viewTime: Float,
|
|
161
|
+
visibilityRatio: Float,
|
|
162
|
+
scrollDepth: Float,
|
|
163
|
+
timeToVisible: Float,
|
|
164
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
165
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
166
|
+
) {
|
|
167
|
+
var builder = AnalyticsRequestDEPRECATED.AnalyticsRequestBuilderDEPRECATED(adUnitID: adSpaceId, isTestMode: isTestEnvironment)
|
|
168
|
+
|
|
169
|
+
let upperBuyType = buyType.uppercased()
|
|
170
|
+
if upperBuyType == "CPM" {
|
|
171
|
+
builder = builder.buildCPMRequest(campaignID: campaignId, bidID: bidId)
|
|
172
|
+
} else if upperBuyType == "FIXED" {
|
|
173
|
+
builder = builder.buildFIXEDRequest(metaData: bidMeta)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let request = builder.trackViewableImpression(
|
|
177
|
+
timeToVisible: timeToVisible,
|
|
178
|
+
scrollDepth: scrollDepth,
|
|
179
|
+
visibilityRatio: visibilityRatio,
|
|
180
|
+
viewTime: viewTime
|
|
181
|
+
).build()
|
|
182
|
+
sendCreativeAnalytics(analyticsRequest: request, resolver: resolver, rejecter: rejecter)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@objc public func trackTotalView(
|
|
186
|
+
campaignId: String,
|
|
187
|
+
adSpaceId: String,
|
|
188
|
+
bidId: String,
|
|
189
|
+
bidMeta: String,
|
|
190
|
+
buyType: String,
|
|
191
|
+
isTestEnvironment: Bool,
|
|
192
|
+
totalViewTime: Float,
|
|
193
|
+
visibilityRatio: Float,
|
|
194
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
195
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
196
|
+
) {
|
|
197
|
+
var builder = AnalyticsRequestDEPRECATED.AnalyticsRequestBuilderDEPRECATED(adUnitID: adSpaceId, isTestMode: isTestEnvironment)
|
|
198
|
+
|
|
199
|
+
let upperBuyType = buyType.uppercased()
|
|
200
|
+
if upperBuyType == "CPM" {
|
|
201
|
+
builder = builder.buildCPMRequest(campaignID: campaignId, bidID: bidId)
|
|
202
|
+
} else if upperBuyType == "FIXED" {
|
|
203
|
+
builder = builder.buildFIXEDRequest(metaData: bidMeta)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let request = builder.trackTotalViewTime(totalViewTime: totalViewTime).build()
|
|
207
|
+
sendCreativeAnalytics(analyticsRequest: request, resolver: resolver, rejecter: rejecter)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@objc public func trackClick(
|
|
211
|
+
campaignId: String,
|
|
212
|
+
adSpaceId: String,
|
|
213
|
+
bidId: String,
|
|
214
|
+
bidMeta: String,
|
|
215
|
+
buyType: String,
|
|
216
|
+
isTestEnvironment: Bool,
|
|
217
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
218
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
219
|
+
) {
|
|
220
|
+
var builder = AnalyticsRequestDEPRECATED.AnalyticsRequestBuilderDEPRECATED(adUnitID: adSpaceId, isTestMode: isTestEnvironment)
|
|
221
|
+
|
|
222
|
+
let upperBuyType = buyType.uppercased()
|
|
223
|
+
if upperBuyType == "CPM" {
|
|
224
|
+
builder = builder.buildCPMRequest(campaignID: campaignId, bidID: bidId)
|
|
225
|
+
} else if upperBuyType == "FIXED" {
|
|
226
|
+
builder = builder.buildFIXEDRequest(metaData: bidMeta)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
let request = builder.trackClick().build()
|
|
230
|
+
sendCreativeAnalytics(analyticsRequest: request, resolver: resolver, rejecter: rejecter)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@objc public func trackVideoPlayback(
|
|
234
|
+
campaignId: String,
|
|
235
|
+
adSpaceId: String,
|
|
236
|
+
bidId: String,
|
|
237
|
+
bidMeta: String,
|
|
238
|
+
buyType: String,
|
|
239
|
+
isTestEnvironment: Bool,
|
|
240
|
+
totalPlaybackTime: Float,
|
|
241
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
242
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
243
|
+
) {
|
|
244
|
+
var builder = AnalyticsRequestDEPRECATED.AnalyticsRequestBuilderDEPRECATED(adUnitID: adSpaceId, isTestMode: isTestEnvironment)
|
|
245
|
+
|
|
246
|
+
let upperBuyType = buyType.uppercased()
|
|
247
|
+
if upperBuyType == "CPM" {
|
|
248
|
+
builder = builder.buildCPMRequest(campaignID: campaignId, bidID: bidId)
|
|
249
|
+
} else if upperBuyType == "FIXED" {
|
|
250
|
+
builder = builder.buildFIXEDRequest(metaData: bidMeta)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
let request = builder.trackTotalPlaybackTime(totalPlaybackTime: totalPlaybackTime).build()
|
|
254
|
+
sendCreativeAnalytics(analyticsRequest: request, resolver: resolver, rejecter: rejecter)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// @objc public func trackVideoQuartile(
|
|
258
|
+
// campaignId: String,
|
|
259
|
+
// adSpaceId: String,
|
|
260
|
+
// bidId: String,
|
|
261
|
+
// bidMeta: String,
|
|
262
|
+
// buyType: String,
|
|
263
|
+
// isTestEnvironment: Bool,
|
|
264
|
+
// quartile: String,
|
|
265
|
+
// resolver: @escaping RCTPromiseResolveBlock,
|
|
266
|
+
// rejecter: @escaping RCTPromiseRejectBlock
|
|
267
|
+
// ) {
|
|
268
|
+
// var builder = AnalyticsRequestDEPRECATED.AnalyticsRequestBuilderDEPRECATED(adUnitID: adSpaceId, isTestMode: isTestEnvironment)
|
|
269
|
+
//
|
|
270
|
+
// let upperBuyType = buyType.uppercased()
|
|
271
|
+
// if upperBuyType == "CPM" {
|
|
272
|
+
// builder = builder.buildCPMRequest(campaignID: campaignId, bidID: bidId)
|
|
273
|
+
// } else if upperBuyType == "FIXED" {
|
|
274
|
+
// builder = builder.buildFIXEDRequest(metaData: bidMeta)
|
|
275
|
+
// }
|
|
276
|
+
//
|
|
277
|
+
// let request = builder.trackVideoQuartile(quartile: quartile).build()
|
|
278
|
+
// sendCreativeAnalytics(analyticsRequest: request, resolver: resolver, rejecter: rejecter)
|
|
279
|
+
// }
|
|
280
|
+
|
|
146
281
|
@objc public static func requiresMainQueueSetup() -> Bool {
|
|
147
282
|
return true
|
|
148
283
|
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#import "NativeHTML5AdManager.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
4
|
+
#import <React/RCTConversions.h>
|
|
5
|
+
#import <React/RCTBridgeModule.h>
|
|
6
|
+
|
|
7
|
+
// Swift → ObjC header
|
|
8
|
+
#if __has_include("Adgeist-Swift.h")
|
|
9
|
+
#import "Adgeist-Swift.h"
|
|
10
|
+
#elif __has_include(<adgeist/adgeist-Swift.h>)
|
|
11
|
+
#import <Adgeist/Adgeist-Swift.h>
|
|
12
|
+
#else
|
|
13
|
+
@import adgeist;
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#import "generated/RNAdgeistSpec/ComponentDescriptors.h"
|
|
17
|
+
#import "generated/RNAdgeistSpec/EventEmitters.h"
|
|
18
|
+
#import "generated/RNAdgeistSpec/Props.h"
|
|
19
|
+
#import "generated/RNAdgeistSpec/RCTComponentViewHelpers.h"
|
|
20
|
+
|
|
21
|
+
using namespace facebook::react;
|
|
22
|
+
|
|
23
|
+
@interface RCTNativeHTML5AdManager () <RCTHTML5AdNativeComponentViewProtocol, NativeHTML5AdDelegate>
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
@implementation RCTNativeHTML5AdManager {
|
|
27
|
+
NativeHTML5AdView *_swiftView;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (instancetype)init
|
|
31
|
+
{
|
|
32
|
+
if (self = [super init]) {
|
|
33
|
+
_swiftView = [[NativeHTML5AdView alloc] initWithFrame:CGRectZero];
|
|
34
|
+
_swiftView.delegate = self;
|
|
35
|
+
[self addSubview:_swiftView];
|
|
36
|
+
}
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)dealloc
|
|
41
|
+
{
|
|
42
|
+
_swiftView.delegate = nil;
|
|
43
|
+
[_swiftView destroy];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (void)prepareForRecycle
|
|
47
|
+
{
|
|
48
|
+
[super prepareForRecycle];
|
|
49
|
+
[_swiftView destroy];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (void)layoutSubviews
|
|
53
|
+
{
|
|
54
|
+
[super layoutSubviews];
|
|
55
|
+
_swiftView.frame = self.bounds;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)didMoveToSuperview
|
|
59
|
+
{
|
|
60
|
+
[super didMoveToSuperview];
|
|
61
|
+
if (self.superview) {
|
|
62
|
+
[_swiftView triggerViewWillAppear];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (void)updateProps:(const facebook::react::Props::Shared &)props
|
|
67
|
+
oldProps:(const facebook::react::Props::Shared &)oldProps
|
|
68
|
+
{
|
|
69
|
+
const auto &newProps = *std::static_pointer_cast<const HTML5AdNativeComponentProps>(props);
|
|
70
|
+
|
|
71
|
+
// Create a default old props if null (without parsing)
|
|
72
|
+
HTML5AdNativeComponentProps defaultOldProps;
|
|
73
|
+
const HTML5AdNativeComponentProps &oldPropsStruct = oldProps
|
|
74
|
+
? *std::static_pointer_cast<const HTML5AdNativeComponentProps>(oldProps)
|
|
75
|
+
: defaultOldProps;
|
|
76
|
+
|
|
77
|
+
if (oldPropsStruct.adUnitID != newProps.adUnitID) {
|
|
78
|
+
_swiftView.adUnitID = newProps.adUnitID.empty()
|
|
79
|
+
? nil
|
|
80
|
+
: [NSString stringWithUTF8String:newProps.adUnitID.c_str()];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (oldPropsStruct.adIsResponsive != newProps.adIsResponsive) {
|
|
84
|
+
_swiftView.adIsResponsive = newProps.adIsResponsive;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (oldPropsStruct.adSize.width != newProps.adSize.width ||
|
|
88
|
+
oldPropsStruct.adSize.height != newProps.adSize.height) {
|
|
89
|
+
|
|
90
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
|
91
|
+
if (newProps.adSize.width != 0.0) {
|
|
92
|
+
dict[@"width"] = @(newProps.adSize.width);
|
|
93
|
+
}
|
|
94
|
+
if (newProps.adSize.height != 0.0) {
|
|
95
|
+
dict[@"height"] = @(newProps.adSize.height);
|
|
96
|
+
}
|
|
97
|
+
_swiftView.adSize = dict.count > 0 ? dict : nil;
|
|
98
|
+
|
|
99
|
+
if (_swiftView.adUnitID != nil) {
|
|
100
|
+
[_swiftView reloadAd];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (oldPropsStruct.adType != newProps.adType) {
|
|
105
|
+
_swiftView.adType = newProps.adType.empty()
|
|
106
|
+
? nil
|
|
107
|
+
: [NSString stringWithUTF8String:newProps.adType.c_str()];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[super updateProps:props oldProps:oldProps];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (void)onAdLoaded
|
|
114
|
+
{
|
|
115
|
+
if (_eventEmitter) {
|
|
116
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
117
|
+
->onAdLoaded(HTML5AdNativeComponentEventEmitter::OnAdLoaded{});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
- (void)onAdFailedToLoad:(NSString *)error
|
|
122
|
+
{
|
|
123
|
+
if (_eventEmitter) {
|
|
124
|
+
HTML5AdNativeComponentEventEmitter::OnAdFailedToLoad event{};
|
|
125
|
+
event.error = error ? std::string([error UTF8String]) : "";
|
|
126
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
127
|
+
->onAdFailedToLoad(event);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
- (void)onAdOpened
|
|
132
|
+
{
|
|
133
|
+
if (_eventEmitter) {
|
|
134
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
135
|
+
->onAdOpened(HTML5AdNativeComponentEventEmitter::OnAdOpened{});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (void)onAdClosed
|
|
140
|
+
{
|
|
141
|
+
if (_eventEmitter) {
|
|
142
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
143
|
+
->onAdClosed(HTML5AdNativeComponentEventEmitter::OnAdClosed{});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
- (void)onAdClicked
|
|
148
|
+
{
|
|
149
|
+
if (_eventEmitter) {
|
|
150
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
151
|
+
->onAdClicked(HTML5AdNativeComponentEventEmitter::OnAdClicked{});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
- (void)handleCommand:(NSString const *)commandName args:(NSArray const *)args
|
|
157
|
+
{
|
|
158
|
+
RCTHTML5AdNativeComponentHandleCommand(self, commandName, args);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
- (void)loadAd:(BOOL)isTestMode
|
|
162
|
+
{
|
|
163
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
|
164
|
+
dict[@"isTestMode"] = @(isTestMode);
|
|
165
|
+
[_swiftView loadAd:dict];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (void)destroy
|
|
169
|
+
{
|
|
170
|
+
[_swiftView destroy];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
174
|
+
{
|
|
175
|
+
return concreteComponentDescriptorProvider<HTML5AdNativeComponentComponentDescriptor>();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import AdgeistKit
|
|
3
|
+
import React
|
|
4
|
+
|
|
5
|
+
// MARK: - Delegate Protocol (Objective-C compatible)
|
|
6
|
+
@objc public protocol NativeHTML5AdDelegate: NSObjectProtocol {
|
|
7
|
+
@objc func onAdLoaded()
|
|
8
|
+
@objc(onAdFailedToLoad:) func onAdFailedToLoad(error: String)
|
|
9
|
+
@objc func onAdOpened()
|
|
10
|
+
@objc func onAdClosed()
|
|
11
|
+
@objc func onAdClicked()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// MARK: - Main Swift View (Exposed to Objective-C++)
|
|
15
|
+
@objc(NativeHTML5AdView)
|
|
16
|
+
@objcMembers
|
|
17
|
+
public class NativeHTML5AdView: UIView {
|
|
18
|
+
|
|
19
|
+
// MARK: Public Props (accessible from .mm)
|
|
20
|
+
@objc public var adUnitID: String?
|
|
21
|
+
@objc public var adSize: NSDictionary?
|
|
22
|
+
@objc public var adType: String?
|
|
23
|
+
@objc public var adIsResponsive: Bool = false
|
|
24
|
+
|
|
25
|
+
// MARK: Delegate (used to send events back to Fabric manager)
|
|
26
|
+
@objc public weak var delegate: NativeHTML5AdDelegate?
|
|
27
|
+
|
|
28
|
+
// MARK: Private Ad View & Listener
|
|
29
|
+
private var adView: AdView?
|
|
30
|
+
private var adListener: NativeHTML5AdListener?
|
|
31
|
+
private var isTestMode: Bool = false
|
|
32
|
+
|
|
33
|
+
public override init(frame: CGRect) {
|
|
34
|
+
super.init(frame: frame)
|
|
35
|
+
backgroundColor = .clear
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@available(*, unavailable)
|
|
39
|
+
required init?(coder: NSCoder) {
|
|
40
|
+
fatalError("init(coder:) has not been implemented")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public override func layoutSubviews() {
|
|
44
|
+
super.layoutSubviews()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@objc public func triggerViewWillAppear() {
|
|
48
|
+
// adView?.resume()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@objc public func reloadAd() {
|
|
52
|
+
cleanupAdView()
|
|
53
|
+
embedAdView()
|
|
54
|
+
setNeedsLayout()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@objc public func loadAd(_ options: NSDictionary) {
|
|
58
|
+
if let testMode = options["isTestMode"] as? Bool {
|
|
59
|
+
self.isTestMode = testMode
|
|
60
|
+
}
|
|
61
|
+
reloadAd()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@objc public func destroy() {
|
|
65
|
+
cleanupAdView()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private func cleanupAdView() {
|
|
69
|
+
adView?.destroy()
|
|
70
|
+
adView?.removeFromSuperview()
|
|
71
|
+
adView = nil
|
|
72
|
+
adListener = nil
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private func embedAdView() {
|
|
76
|
+
guard let adUnitID = adUnitID else {
|
|
77
|
+
delegate?.onAdFailedToLoad(error: "Ad unit ID is required")
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let adView = AdView()
|
|
82
|
+
adView.frame = bounds
|
|
83
|
+
adView.adUnitId = adUnitID
|
|
84
|
+
adView.adIsResposive = adIsResponsive
|
|
85
|
+
|
|
86
|
+
if let dict = adSize as? [String: Any] {
|
|
87
|
+
if let w = dict["width"] as? Int, let h = dict["height"] as? Int {
|
|
88
|
+
adView.setAdDimension(AdSize(width: w, height: h))
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if let adType = adType { adView.adType = adType }
|
|
93
|
+
|
|
94
|
+
let listener = NativeHTML5AdListener(view: self)
|
|
95
|
+
self.adListener = listener
|
|
96
|
+
adView.setAdListener(listener)
|
|
97
|
+
|
|
98
|
+
self.adView = adView
|
|
99
|
+
addSubview(adView)
|
|
100
|
+
|
|
101
|
+
let request = AdRequest.AdRequestBuilder()
|
|
102
|
+
.setTestMode(self.isTestMode)
|
|
103
|
+
.build()
|
|
104
|
+
adView.loadAd(request)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// MARK: - Ad Listener (Bridge to delegate)
|
|
109
|
+
private class NativeHTML5AdListener: AdListener {
|
|
110
|
+
private weak var view: NativeHTML5AdView?
|
|
111
|
+
|
|
112
|
+
init(view: NativeHTML5AdView) {
|
|
113
|
+
self.view = view
|
|
114
|
+
super.init()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
override func onAdLoaded() {
|
|
118
|
+
view?.delegate?.onAdLoaded()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
override func onAdFailedToLoad(_ errorMessage: String) {
|
|
122
|
+
view?.delegate?.onAdFailedToLoad(error: errorMessage)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override func onAdClicked() {
|
|
126
|
+
view?.delegate?.onAdClicked()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override func onAdImpression() {
|
|
130
|
+
view?.delegate?.onAdOpened()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
override func onAdClosed() {
|
|
134
|
+
view?.delegate?.onAdClosed()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ComponentDescriptors.h"
|
|
12
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
13
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
void RNAdgeistSpec_registerComponentDescriptorsFromCodegen(
|
|
18
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
|
+
registry->add(concreteComponentDescriptorProvider<HTML5AdNativeComponentComponentDescriptor>());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ShadowNodes.h"
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
using HTML5AdNativeComponentComponentDescriptor = ConcreteComponentDescriptor<HTML5AdNativeComponentShadowNode>;
|
|
20
|
+
|
|
21
|
+
void RNAdgeistSpec_registerComponentDescriptorsFromCodegen(
|
|
22
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|