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.
- package/README.md +40 -649
- package/android/build.gradle +1 -2
- package/android/src/main/java/com/cloudxreactnative/CloudXModuleImpl.kt +134 -27
- package/android/src/newarch/com/cloudxreactnative/CloudXModule.kt +5 -0
- package/android/src/oldarch/com/cloudxreactnative/CloudXModule.kt +23 -2
- package/cloudx-react-native.podspec +1 -1
- package/ios/CloudX.mm +215 -0
- package/lib/commonjs/CloudXBannerAd.js +4 -0
- package/lib/commonjs/CloudXBannerAd.js.map +1 -1
- package/lib/commonjs/CloudXInterstitialAd.js +4 -0
- package/lib/commonjs/CloudXInterstitialAd.js.map +1 -1
- package/lib/commonjs/CloudXMRECAd.js +4 -0
- package/lib/commonjs/CloudXMRECAd.js.map +1 -1
- package/lib/commonjs/CloudXRewardedAd.js +4 -0
- package/lib/commonjs/CloudXRewardedAd.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeCloudX.js.map +1 -1
- package/lib/commonjs/types/ExtraParameters.js +2 -0
- package/lib/commonjs/types/ExtraParameters.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/CloudXBannerAd.js +4 -0
- package/lib/module/CloudXBannerAd.js.map +1 -1
- package/lib/module/CloudXInterstitialAd.js +4 -0
- package/lib/module/CloudXInterstitialAd.js.map +1 -1
- package/lib/module/CloudXMRECAd.js +4 -0
- package/lib/module/CloudXMRECAd.js.map +1 -1
- package/lib/module/CloudXRewardedAd.js +4 -0
- package/lib/module/CloudXRewardedAd.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeCloudX.js.map +1 -1
- package/lib/module/types/ExtraParameters.js +2 -0
- package/lib/module/types/ExtraParameters.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/CloudXBannerAd.d.ts.map +1 -1
- package/lib/typescript/src/CloudXInterstitialAd.d.ts.map +1 -1
- package/lib/typescript/src/CloudXMRECAd.d.ts.map +1 -1
- package/lib/typescript/src/CloudXRewardedAd.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeCloudX.d.ts +5 -0
- package/lib/typescript/src/specs/NativeCloudX.d.ts.map +1 -1
- package/lib/typescript/src/types/ExtraParameters.d.ts +7 -0
- package/lib/typescript/src/types/ExtraParameters.d.ts.map +1 -0
- package/lib/typescript/src/types/FullscreenAd.d.ts +3 -0
- package/lib/typescript/src/types/FullscreenAd.d.ts.map +1 -1
- package/lib/typescript/src/types/ViewAd.d.ts +2 -0
- package/lib/typescript/src/types/ViewAd.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +3 -1
- package/src/CloudXBannerAd.ts +6 -0
- package/src/CloudXInterstitialAd.ts +6 -0
- package/src/CloudXMRECAd.ts +6 -0
- package/src/CloudXRewardedAd.ts +6 -0
- package/src/index.ts +2 -0
- package/src/specs/NativeCloudX.ts +5 -0
- package/src/types/ExtraParameters.ts +11 -0
- package/src/types/FullscreenAd.ts +4 -0
- package/src/types/ViewAd.ts +2 -0
- package/src/types/index.ts +1 -0
- package/src/version.ts +1 -1
package/android/build.gradle
CHANGED
|
@@ -65,7 +65,6 @@ android {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
repositories {
|
|
68
|
-
mavenLocal()
|
|
69
68
|
mavenCentral()
|
|
70
69
|
google()
|
|
71
70
|
}
|
|
@@ -73,5 +72,5 @@ repositories {
|
|
|
73
72
|
dependencies {
|
|
74
73
|
implementation "com.facebook.react:react-native:0.76.2"
|
|
75
74
|
|
|
76
|
-
implementation "io.cloudx:sdk:
|
|
75
|
+
implementation "io.cloudx:sdk:4.1.0"
|
|
77
76
|
}
|
|
@@ -13,6 +13,9 @@ import com.facebook.react.bridge.Arguments
|
|
|
13
13
|
import com.facebook.react.bridge.LifecycleEventListener
|
|
14
14
|
import com.facebook.react.bridge.Promise
|
|
15
15
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
16
|
+
import com.facebook.react.bridge.ReadableArray
|
|
17
|
+
import com.facebook.react.bridge.ReadableMap
|
|
18
|
+
import com.facebook.react.bridge.ReadableType
|
|
16
19
|
import com.facebook.react.bridge.WritableMap
|
|
17
20
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
18
21
|
import io.cloudx.sdk.CloudX
|
|
@@ -45,6 +48,7 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
45
48
|
private val adViewAdFormats = ConcurrentHashMap<String, CloudXAdFormat>()
|
|
46
49
|
private val adViewPositions = ConcurrentHashMap<String, String>()
|
|
47
50
|
private val adViewOffsetsDp = ConcurrentHashMap<String, Pair<Float, Float>>()
|
|
51
|
+
private val adViewExtraParameters = ConcurrentHashMap<String, ConcurrentHashMap<String, Any>>()
|
|
48
52
|
private val adUnitIdsToShowAfterCreate = ConcurrentHashMap.newKeySet<String>()
|
|
49
53
|
// Workaround for React Native bug where getCurrentActivity() returns null:
|
|
50
54
|
// https://github.com/facebook/react-native/issues/18345
|
|
@@ -170,6 +174,7 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
170
174
|
fun setBannerBackgroundColor(adUnitId: String, hexColorString: String) = setAdViewBackgroundColor(adUnitId, CloudXAdFormat.BANNER, hexColorString)
|
|
171
175
|
fun setBannerPlacement(adUnitId: String, placement: String?) = setAdViewPlacement(adUnitId, CloudXAdFormat.BANNER, placement)
|
|
172
176
|
fun setBannerCustomData(adUnitId: String, customData: String?) = setAdViewCustomData(adUnitId, CloudXAdFormat.BANNER, customData)
|
|
177
|
+
fun setBannerExtraParameters(adUnitId: String, extraParameters: ReadableMap) = setAdViewExtraParameters(adUnitId, CloudXAdFormat.BANNER, extraParameters)
|
|
173
178
|
fun updateBannerPosition(adUnitId: String, position: String) = updateAdViewPosition(adUnitId, CloudXAdFormat.BANNER, position, adViewOffsetsDp[adUnitId] ?: DEFAULT_AD_VIEW_OFFSET_DP)
|
|
174
179
|
fun updateBannerOffsets(adUnitId: String, xOffset: Double, yOffset: Double) = updateAdViewPosition(adUnitId, CloudXAdFormat.BANNER, adViewPositions[adUnitId], Pair(xOffset.toFloat(), yOffset.toFloat()))
|
|
175
180
|
fun startBannerAutoRefresh(adUnitId: String) = startAdViewAutoRefresh(adUnitId, CloudXAdFormat.BANNER)
|
|
@@ -187,6 +192,7 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
187
192
|
fun setMRECBackgroundColor(adUnitId: String, hexColorString: String) = setAdViewBackgroundColor(adUnitId, CloudXAdFormat.MREC, hexColorString)
|
|
188
193
|
fun setMRECPlacement(adUnitId: String, placement: String?) = setAdViewPlacement(adUnitId, CloudXAdFormat.MREC, placement)
|
|
189
194
|
fun setMRECCustomData(adUnitId: String, customData: String?) = setAdViewCustomData(adUnitId, CloudXAdFormat.MREC, customData)
|
|
195
|
+
fun setMRECExtraParameters(adUnitId: String, extraParameters: ReadableMap) = setAdViewExtraParameters(adUnitId, CloudXAdFormat.MREC, extraParameters)
|
|
190
196
|
fun updateMRECPosition(adUnitId: String, position: String) = updateAdViewPosition(adUnitId, CloudXAdFormat.MREC, position, adViewOffsetsDp[adUnitId] ?: DEFAULT_AD_VIEW_OFFSET_DP)
|
|
191
197
|
fun updateMRECOffsets(adUnitId: String, xOffset: Double, yOffset: Double) = updateAdViewPosition(adUnitId, CloudXAdFormat.MREC, adViewPositions[adUnitId], Pair(xOffset.toFloat(), yOffset.toFloat()))
|
|
192
198
|
fun startMRECAutoRefresh(adUnitId: String) = startAdViewAutoRefresh(adUnitId, CloudXAdFormat.MREC)
|
|
@@ -203,25 +209,35 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
203
209
|
retrieveInterstitial(adUnitId).load()
|
|
204
210
|
}
|
|
205
211
|
|
|
212
|
+
fun setInterstitialExtraParameters(adUnitId: String, extraParameters: ReadableMap) {
|
|
213
|
+
applyExtraParameters(extraParameters) { key, value ->
|
|
214
|
+
retrieveInterstitial(adUnitId).setExtraParameter(key, value)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
206
218
|
fun isInterstitialReady(adUnitId: String, promise: Promise) {
|
|
207
219
|
promise.resolve(retrieveInterstitial(adUnitId).isAdReady)
|
|
208
220
|
}
|
|
209
221
|
|
|
210
222
|
fun showInterstitial(adUnitId: String, placement: String?, customData: String?) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
223
|
+
reactApplicationContext.runOnUiQueueThread {
|
|
224
|
+
val interstitial = retrieveInterstitial(adUnitId)
|
|
225
|
+
val activity = maybeGetCurrentActivity()
|
|
226
|
+
if (activity == null) {
|
|
227
|
+
Log.e(TAG, "showInterstitial: no activity available")
|
|
228
|
+
return@runOnUiQueueThread
|
|
229
|
+
}
|
|
230
|
+
interstitial.show(activity, placement, customData)
|
|
216
231
|
}
|
|
217
|
-
interstitial.show(activity, placement, customData)
|
|
218
232
|
}
|
|
219
233
|
|
|
220
234
|
fun destroyInterstitial(adUnitId: String) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
235
|
+
reactApplicationContext.runOnUiQueueThread {
|
|
236
|
+
interstitials.remove(adUnitId)?.let {
|
|
237
|
+
it.listener = null
|
|
238
|
+
it.revenueListener = null
|
|
239
|
+
it.destroy()
|
|
240
|
+
}
|
|
225
241
|
}
|
|
226
242
|
}
|
|
227
243
|
|
|
@@ -233,25 +249,35 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
233
249
|
retrieveRewarded(adUnitId).load()
|
|
234
250
|
}
|
|
235
251
|
|
|
252
|
+
fun setRewardedExtraParameters(adUnitId: String, extraParameters: ReadableMap) {
|
|
253
|
+
applyExtraParameters(extraParameters) { key, value ->
|
|
254
|
+
retrieveRewarded(adUnitId).setExtraParameter(key, value)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
236
258
|
fun isRewardedReady(adUnitId: String, promise: Promise) {
|
|
237
259
|
promise.resolve(retrieveRewarded(adUnitId).isAdReady)
|
|
238
260
|
}
|
|
239
261
|
|
|
240
262
|
fun showRewarded(adUnitId: String, placement: String?, customData: String?) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
263
|
+
reactApplicationContext.runOnUiQueueThread {
|
|
264
|
+
val rewarded = retrieveRewarded(adUnitId)
|
|
265
|
+
val activity = maybeGetCurrentActivity()
|
|
266
|
+
if (activity == null) {
|
|
267
|
+
Log.e(TAG, "showRewarded: no activity available")
|
|
268
|
+
return@runOnUiQueueThread
|
|
269
|
+
}
|
|
270
|
+
rewarded.show(activity, placement, customData)
|
|
246
271
|
}
|
|
247
|
-
rewarded.show(activity, placement, customData)
|
|
248
272
|
}
|
|
249
273
|
|
|
250
274
|
fun destroyRewarded(adUnitId: String) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
275
|
+
reactApplicationContext.runOnUiQueueThread {
|
|
276
|
+
rewardedAds.remove(adUnitId)?.let {
|
|
277
|
+
it.listener = null
|
|
278
|
+
it.revenueListener = null
|
|
279
|
+
it.destroy()
|
|
280
|
+
}
|
|
255
281
|
}
|
|
256
282
|
}
|
|
257
283
|
|
|
@@ -383,6 +409,7 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
383
409
|
?: return@runOnUiQueueThread
|
|
384
410
|
|
|
385
411
|
adViewAdFormats[adUnitId] = adFormat
|
|
412
|
+
applyPendingExtraParameters(adUnitId, adView)
|
|
386
413
|
|
|
387
414
|
adView.load()
|
|
388
415
|
|
|
@@ -408,6 +435,83 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
408
435
|
}
|
|
409
436
|
}
|
|
410
437
|
|
|
438
|
+
private fun setAdViewExtraParameters(adUnitId: String, adFormat: CloudXAdFormat, extraParameters: ReadableMap) {
|
|
439
|
+
reactApplicationContext.runOnUiQueueThread {
|
|
440
|
+
val adView = retrieveAdView(adUnitId, adFormat)
|
|
441
|
+
if (adView != null) {
|
|
442
|
+
applyExtraParameters(extraParameters) { key, value ->
|
|
443
|
+
adView.setExtraParameter(key, value)
|
|
444
|
+
}
|
|
445
|
+
return@runOnUiQueueThread
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
val pending = adViewExtraParameters.getOrPut(adUnitId) { ConcurrentHashMap() }
|
|
449
|
+
applyExtraParameters(extraParameters) { key, value ->
|
|
450
|
+
if (value == null) {
|
|
451
|
+
pending.remove(key)
|
|
452
|
+
} else {
|
|
453
|
+
pending[key] = value
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
private fun applyPendingExtraParameters(adUnitId: String, adView: SdkAdView) {
|
|
460
|
+
val pending = adViewExtraParameters[adUnitId] ?: return
|
|
461
|
+
for ((key, value) in pending) {
|
|
462
|
+
adView.setExtraParameter(key, value)
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
private fun applyExtraParameters(extraParameters: ReadableMap, apply: (String, Any?) -> Unit) {
|
|
467
|
+
val iterator = extraParameters.keySetIterator()
|
|
468
|
+
while (iterator.hasNextKey()) {
|
|
469
|
+
val key = iterator.nextKey()
|
|
470
|
+
if (key.isBlank()) continue
|
|
471
|
+
apply(key, readableMapValue(extraParameters, key))
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
private fun readableMapValue(map: ReadableMap, key: String): Any? {
|
|
476
|
+
return when (map.getType(key)) {
|
|
477
|
+
ReadableType.Null -> null
|
|
478
|
+
ReadableType.Boolean -> map.getBoolean(key)
|
|
479
|
+
ReadableType.Number -> map.getDouble(key)
|
|
480
|
+
ReadableType.String -> map.getString(key)
|
|
481
|
+
ReadableType.Map -> map.getMap(key)?.let(::readableMapToMap)
|
|
482
|
+
ReadableType.Array -> map.getArray(key)?.let(::readableArrayToList)
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
private fun readableMapToMap(readableMap: ReadableMap): Map<String, Any?> {
|
|
487
|
+
val result = mutableMapOf<String, Any?>()
|
|
488
|
+
val iterator = readableMap.keySetIterator()
|
|
489
|
+
while (iterator.hasNextKey()) {
|
|
490
|
+
val key = iterator.nextKey()
|
|
491
|
+
result[key] = readableMapValue(readableMap, key)
|
|
492
|
+
}
|
|
493
|
+
return result
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
private fun readableArrayToList(readableArray: ReadableArray): List<Any?> {
|
|
497
|
+
val result = mutableListOf<Any?>()
|
|
498
|
+
for (index in 0 until readableArray.size()) {
|
|
499
|
+
result.add(readableArrayValue(readableArray, index))
|
|
500
|
+
}
|
|
501
|
+
return result
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
private fun readableArrayValue(array: ReadableArray, index: Int): Any? {
|
|
505
|
+
return when (array.getType(index)) {
|
|
506
|
+
ReadableType.Null -> null
|
|
507
|
+
ReadableType.Boolean -> array.getBoolean(index)
|
|
508
|
+
ReadableType.Number -> array.getDouble(index)
|
|
509
|
+
ReadableType.String -> array.getString(index)
|
|
510
|
+
ReadableType.Map -> array.getMap(index)?.let(::readableMapToMap)
|
|
511
|
+
ReadableType.Array -> array.getArray(index)?.let(::readableArrayToList)
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
411
515
|
private fun updateAdViewPosition(adUnitId: String, adFormat: CloudXAdFormat, position: String?, offsetsDp: Pair<Float, Float>) {
|
|
412
516
|
reactApplicationContext.runOnUiQueueThread {
|
|
413
517
|
val adView = retrieveAdView(adUnitId, adFormat) ?: return@runOnUiQueueThread
|
|
@@ -466,6 +570,7 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
466
570
|
adViewAdFormats.remove(adUnitId)
|
|
467
571
|
adViewPositions.remove(adUnitId)
|
|
468
572
|
adViewOffsetsDp.remove(adUnitId)
|
|
573
|
+
adViewExtraParameters.remove(adUnitId)
|
|
469
574
|
adUnitIdsToShowAfterCreate.remove(adUnitId)
|
|
470
575
|
}
|
|
471
576
|
}
|
|
@@ -661,15 +766,17 @@ class CloudXModuleImpl(private val reactApplicationContext: ReactApplicationCont
|
|
|
661
766
|
destroyAdView(adUnitId, adFormat)
|
|
662
767
|
}
|
|
663
768
|
|
|
664
|
-
|
|
665
|
-
interstitial.
|
|
666
|
-
|
|
667
|
-
|
|
769
|
+
reactApplicationContext.runOnUiQueueThread {
|
|
770
|
+
for (interstitial in interstitials.values) {
|
|
771
|
+
interstitial.destroy()
|
|
772
|
+
}
|
|
773
|
+
interstitials.clear()
|
|
668
774
|
|
|
669
|
-
|
|
670
|
-
|
|
775
|
+
for (rewarded in rewardedAds.values) {
|
|
776
|
+
rewarded.destroy()
|
|
777
|
+
}
|
|
778
|
+
rewardedAds.clear()
|
|
671
779
|
}
|
|
672
|
-
rewardedAds.clear()
|
|
673
780
|
}
|
|
674
781
|
|
|
675
782
|
// =========================================================================
|
|
@@ -4,6 +4,7 @@ import com.facebook.fbreact.specs.NativeCloudXSpec
|
|
|
4
4
|
import com.facebook.react.bridge.Promise
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
8
|
import com.facebook.react.module.annotations.ReactModule
|
|
8
9
|
|
|
9
10
|
@ReactModule(name = CloudXModuleImpl.MODULE_NAME)
|
|
@@ -35,6 +36,7 @@ class CloudXModule(reactContext: ReactApplicationContext) :
|
|
|
35
36
|
@ReactMethod override fun setBannerBackgroundColor(adUnitId: String, hexColorString: String) = impl.setBannerBackgroundColor(adUnitId, hexColorString)
|
|
36
37
|
@ReactMethod override fun setBannerPlacement(adUnitId: String, placement: String?) = impl.setBannerPlacement(adUnitId, placement)
|
|
37
38
|
@ReactMethod override fun setBannerCustomData(adUnitId: String, customData: String?) = impl.setBannerCustomData(adUnitId, customData)
|
|
39
|
+
@ReactMethod override fun setBannerExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setBannerExtraParameters(adUnitId, extraParameters)
|
|
38
40
|
@ReactMethod override fun updateBannerPosition(adUnitId: String, position: String) = impl.updateBannerPosition(adUnitId, position)
|
|
39
41
|
@ReactMethod override fun updateBannerOffsets(adUnitId: String, xOffset: Double, yOffset: Double) = impl.updateBannerOffsets(adUnitId, xOffset, yOffset)
|
|
40
42
|
@ReactMethod override fun startBannerAutoRefresh(adUnitId: String) = impl.startBannerAutoRefresh(adUnitId)
|
|
@@ -47,6 +49,7 @@ class CloudXModule(reactContext: ReactApplicationContext) :
|
|
|
47
49
|
@ReactMethod override fun createMRECWithOffsets(adUnitId: String, position: String, xOffset: Double, yOffset: Double) = impl.createMRECWithOffsets(adUnitId, position, xOffset, yOffset)
|
|
48
50
|
@ReactMethod override fun setMRECPlacement(adUnitId: String, placement: String?) = impl.setMRECPlacement(adUnitId, placement)
|
|
49
51
|
@ReactMethod override fun setMRECCustomData(adUnitId: String, customData: String?) = impl.setMRECCustomData(adUnitId, customData)
|
|
52
|
+
@ReactMethod override fun setMRECExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setMRECExtraParameters(adUnitId, extraParameters)
|
|
50
53
|
@ReactMethod override fun updateMRECPosition(adUnitId: String, position: String) = impl.updateMRECPosition(adUnitId, position)
|
|
51
54
|
@ReactMethod override fun updateMRECOffsets(adUnitId: String, xOffset: Double, yOffset: Double) = impl.updateMRECOffsets(adUnitId, xOffset, yOffset)
|
|
52
55
|
@ReactMethod override fun startMRECAutoRefresh(adUnitId: String) = impl.startMRECAutoRefresh(adUnitId)
|
|
@@ -57,11 +60,13 @@ class CloudXModule(reactContext: ReactApplicationContext) :
|
|
|
57
60
|
@ReactMethod override fun setMRECBackgroundColor(adUnitId: String, hexColorString: String) = impl.setMRECBackgroundColor(adUnitId, hexColorString)
|
|
58
61
|
|
|
59
62
|
@ReactMethod override fun loadInterstitial(adUnitId: String) = impl.loadInterstitial(adUnitId)
|
|
63
|
+
@ReactMethod override fun setInterstitialExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setInterstitialExtraParameters(adUnitId, extraParameters)
|
|
60
64
|
@ReactMethod override fun isInterstitialReady(adUnitId: String, promise: Promise) = impl.isInterstitialReady(adUnitId, promise)
|
|
61
65
|
@ReactMethod override fun showInterstitial(adUnitId: String, placement: String?, customData: String?) = impl.showInterstitial(adUnitId, placement, customData)
|
|
62
66
|
@ReactMethod override fun destroyInterstitial(adUnitId: String) = impl.destroyInterstitial(adUnitId)
|
|
63
67
|
|
|
64
68
|
@ReactMethod override fun loadRewarded(adUnitId: String) = impl.loadRewarded(adUnitId)
|
|
69
|
+
@ReactMethod override fun setRewardedExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setRewardedExtraParameters(adUnitId, extraParameters)
|
|
65
70
|
@ReactMethod override fun isRewardedReady(adUnitId: String, promise: Promise) = impl.isRewardedReady(adUnitId, promise)
|
|
66
71
|
@ReactMethod override fun showRewarded(adUnitId: String, placement: String?, customData: String?) = impl.showRewarded(adUnitId, placement, customData)
|
|
67
72
|
@ReactMethod override fun destroyRewarded(adUnitId: String) = impl.destroyRewarded(adUnitId)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
package com.cloudxreactnative
|
|
2
2
|
|
|
3
|
+
import com.facebook.react.bridge.Dynamic
|
|
3
4
|
import com.facebook.react.bridge.Promise
|
|
4
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
7
|
import com.facebook.react.bridge.ReactMethod
|
|
8
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
9
|
|
|
8
10
|
class CloudXModule(reactContext: ReactApplicationContext) :
|
|
9
11
|
ReactContextBaseJavaModule(reactContext) {
|
|
@@ -25,14 +27,30 @@ class CloudXModule(reactContext: ReactApplicationContext) :
|
|
|
25
27
|
@ReactMethod fun setAppKeyValue(key: String, value: String) = impl.setAppKeyValue(key, value)
|
|
26
28
|
@ReactMethod fun clearAllKeyValues() = impl.clearAllKeyValues()
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
// Paper's `JavaMethodWrapper` extracts primitive boxed types via
|
|
31
|
+
// `ReadableNativeArray.getBoolean(int)` which unconditionally calls
|
|
32
|
+
// `booleanValue()` on the boxed result — null arguments therefore throw
|
|
33
|
+
// `NativeArgumentsParseException` *before* the method runs, even when the
|
|
34
|
+
// Kotlin signature is `Boolean?`. Declaring the parameter as `Dynamic`
|
|
35
|
+
// lets the bridge hand us the raw value and we null-check it ourselves.
|
|
36
|
+
// TurboModules (NewArch) don't have this limitation, which is why the
|
|
37
|
+
// newarch counterpart keeps the `Boolean?` signature directly.
|
|
38
|
+
@ReactMethod fun setHasUserConsent(hasUserConsent: Dynamic) {
|
|
39
|
+
val value: Boolean? = if (hasUserConsent.isNull) null else hasUserConsent.asBoolean()
|
|
40
|
+
impl.setHasUserConsent(value)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@ReactMethod fun setDoNotSell(isDoNotSell: Dynamic) {
|
|
44
|
+
val value: Boolean? = if (isDoNotSell.isNull) null else isDoNotSell.asBoolean()
|
|
45
|
+
impl.setDoNotSell(value)
|
|
46
|
+
}
|
|
30
47
|
|
|
31
48
|
@ReactMethod fun createBanner(adUnitId: String, position: String) = impl.createBanner(adUnitId, position)
|
|
32
49
|
@ReactMethod fun createBannerWithOffsets(adUnitId: String, position: String, xOffset: Double, yOffset: Double) = impl.createBannerWithOffsets(adUnitId, position, xOffset, yOffset)
|
|
33
50
|
@ReactMethod fun setBannerBackgroundColor(adUnitId: String, hexColorString: String) = impl.setBannerBackgroundColor(adUnitId, hexColorString)
|
|
34
51
|
@ReactMethod fun setBannerPlacement(adUnitId: String, placement: String?) = impl.setBannerPlacement(adUnitId, placement)
|
|
35
52
|
@ReactMethod fun setBannerCustomData(adUnitId: String, customData: String?) = impl.setBannerCustomData(adUnitId, customData)
|
|
53
|
+
@ReactMethod fun setBannerExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setBannerExtraParameters(adUnitId, extraParameters)
|
|
36
54
|
@ReactMethod fun updateBannerPosition(adUnitId: String, position: String) = impl.updateBannerPosition(adUnitId, position)
|
|
37
55
|
@ReactMethod fun updateBannerOffsets(adUnitId: String, xOffset: Double, yOffset: Double) = impl.updateBannerOffsets(adUnitId, xOffset, yOffset)
|
|
38
56
|
@ReactMethod fun startBannerAutoRefresh(adUnitId: String) = impl.startBannerAutoRefresh(adUnitId)
|
|
@@ -45,6 +63,7 @@ class CloudXModule(reactContext: ReactApplicationContext) :
|
|
|
45
63
|
@ReactMethod fun createMRECWithOffsets(adUnitId: String, position: String, xOffset: Double, yOffset: Double) = impl.createMRECWithOffsets(adUnitId, position, xOffset, yOffset)
|
|
46
64
|
@ReactMethod fun setMRECPlacement(adUnitId: String, placement: String?) = impl.setMRECPlacement(adUnitId, placement)
|
|
47
65
|
@ReactMethod fun setMRECCustomData(adUnitId: String, customData: String?) = impl.setMRECCustomData(adUnitId, customData)
|
|
66
|
+
@ReactMethod fun setMRECExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setMRECExtraParameters(adUnitId, extraParameters)
|
|
48
67
|
@ReactMethod fun updateMRECPosition(adUnitId: String, position: String) = impl.updateMRECPosition(adUnitId, position)
|
|
49
68
|
@ReactMethod fun updateMRECOffsets(adUnitId: String, xOffset: Double, yOffset: Double) = impl.updateMRECOffsets(adUnitId, xOffset, yOffset)
|
|
50
69
|
@ReactMethod fun startMRECAutoRefresh(adUnitId: String) = impl.startMRECAutoRefresh(adUnitId)
|
|
@@ -55,11 +74,13 @@ class CloudXModule(reactContext: ReactApplicationContext) :
|
|
|
55
74
|
@ReactMethod fun setMRECBackgroundColor(adUnitId: String, hexColorString: String) = impl.setMRECBackgroundColor(adUnitId, hexColorString)
|
|
56
75
|
|
|
57
76
|
@ReactMethod fun loadInterstitial(adUnitId: String) = impl.loadInterstitial(adUnitId)
|
|
77
|
+
@ReactMethod fun setInterstitialExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setInterstitialExtraParameters(adUnitId, extraParameters)
|
|
58
78
|
@ReactMethod fun isInterstitialReady(adUnitId: String, promise: Promise) = impl.isInterstitialReady(adUnitId, promise)
|
|
59
79
|
@ReactMethod fun showInterstitial(adUnitId: String, placement: String?, customData: String?) = impl.showInterstitial(adUnitId, placement, customData)
|
|
60
80
|
@ReactMethod fun destroyInterstitial(adUnitId: String) = impl.destroyInterstitial(adUnitId)
|
|
61
81
|
|
|
62
82
|
@ReactMethod fun loadRewarded(adUnitId: String) = impl.loadRewarded(adUnitId)
|
|
83
|
+
@ReactMethod fun setRewardedExtraParameters(adUnitId: String, extraParameters: ReadableMap) = impl.setRewardedExtraParameters(adUnitId, extraParameters)
|
|
63
84
|
@ReactMethod fun isRewardedReady(adUnitId: String, promise: Promise) = impl.isRewardedReady(adUnitId, promise)
|
|
64
85
|
@ReactMethod fun showRewarded(adUnitId: String, placement: String?, customData: String?) = impl.showRewarded(adUnitId, placement, customData)
|
|
65
86
|
@ReactMethod fun destroyRewarded(adUnitId: String) = impl.destroyRewarded(adUnitId)
|