react-native-daro 1.0.16 → 2.0.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 +2 -5
- package/android/build.gradle +7 -13
- package/android/src/main/java/com/daro/reactnative/DaroRNAdBannerViewManager.kt +105 -0
- package/android/src/main/java/com/daro/reactnative/{DaroMAdNativeViewManager.kt → DaroRNAdNativeViewManager.kt} +34 -38
- package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +388 -0
- package/android/src/main/java/com/daro/reactnative/{DaroMPackage.kt → DaroRNPackage.kt} +7 -7
- package/android/src/main/java/com/daro/reactnative/DaroSdkBridge.kt +52 -0
- package/android/src/main/java/com/daro/reactnative/constants/{InternalDaroMBannerSize.kt → InternalDaroRNBannerSize.kt} +2 -2
- package/android/src/main/java/com/daro/reactnative/event/{DaroMEvent.kt → DaroRNEvent.kt} +8 -7
- package/android/src/main/java/com/daro/reactnative/impl/{DaroMBannerViewModuleImpl.kt → DaroRNBannerViewModuleImpl.kt} +3 -3
- package/android/src/main/java/com/daro/reactnative/impl/{DaroMInterstitialModuleImpl.kt → DaroRNInterstitialModuleImpl.kt} +4 -4
- package/android/src/main/java/com/daro/reactnative/impl/DaroRNLightPopupModuleImpl.kt +163 -0
- package/android/src/main/java/com/daro/reactnative/impl/{DaroMRewardedAdModuleImpl.kt → DaroRNRewardedAdModuleImpl.kt} +4 -4
- package/android/src/main/java/com/daro/reactnative/impl/LightPopupRequest.kt +51 -0
- package/android/src/main/java/com/daro/reactnative/util/AdInfoUtil.kt +12 -0
- package/android/src/main/java/com/daro/reactnative/util/DaroQaProbe.kt +147 -0
- package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +2 -2
- package/android/src/main/java/com/daro/reactnative/view/{DaroMAdBannerViewContainer.kt → DaroRNAdBannerViewContainer.kt} +2 -3
- package/android/src/main/java/com/daro/reactnative/view/{DaroMAdNativeViewContainer.kt → DaroRNAdNativeViewContainer.kt} +23 -4
- package/android/src/newarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt} +1 -1
- package/android/src/oldarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt} +35 -3
- package/android/src/test/java/com/daro/reactnative/impl/LightPopupRequestTest.kt +62 -0
- package/ios/{DaroMModule+AppOpen.swift → DaroRNModule+AppOpen.swift} +10 -11
- package/ios/DaroRNModule+Consent.swift +88 -0
- package/ios/{DaroMModule+Interstitial.swift → DaroRNModule+Interstitial.swift} +9 -9
- package/ios/DaroRNModule+LightPopup.swift +211 -0
- package/ios/DaroRNModule+Qa.swift +159 -0
- package/ios/{DaroMModule+Rewarded.swift → DaroRNModule+Rewarded.swift} +10 -10
- package/ios/{DaroMModule.mm → DaroRNModule.mm} +20 -4
- package/ios/{DaroMModule.swift → DaroRNModule.swift} +32 -6
- package/ios/Fabric/DaroRNAdBannerComponentView.mm +219 -0
- package/ios/Fabric/{DaroMFabricEventSink.mm → DaroRNFabricEventSink.mm} +4 -4
- package/ios/Fabric/{DaroMFabricPropApplier.mm → DaroRNFabricPropApplier.mm} +14 -14
- package/ios/Fabric/DaroRNNativeAdComponentView.mm +320 -0
- package/ios/Paper/{DaroMAdBannerViewManager.m → DaroRNAdBannerViewManager.m} +1 -1
- package/ios/Paper/{DaroMAdBannerViewManager.swift → DaroRNAdBannerViewManager.swift} +5 -5
- package/ios/Paper/{DaroMNativeAdViewManager.m → DaroRNNativeAdViewManager.m} +2 -1
- package/ios/Paper/DaroRNNativeAdViewManager.swift +22 -0
- package/ios/Shared/DaroMediationDebugger.swift +14 -0
- package/ios/Shared/{DaroMAdEventSink.swift → DaroRNAdEventSink.swift} +2 -1
- package/ios/Shared/{DaroMBannerAdView.swift → DaroRNBannerAdView.swift} +11 -11
- package/ios/Shared/{DaroMNativeAdLoadCoordinator.swift → DaroRNNativeAdLoadCoordinator.swift} +4 -4
- package/ios/Shared/{DaroMNativeAdView.swift → DaroRNNativeAdView.swift} +29 -21
- package/ios/Shared/{DaroMNativeAssetResolver.swift → DaroRNNativeAssetResolver.swift} +6 -6
- package/lib/commonjs/AdBannerView.js +3 -5
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +4 -4
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/{DaroMAdBannerViewNativeComponent.ts → DaroRNAdBannerViewNativeComponent.ts} +5 -2
- package/{src/DaroMNativeAdViewNativeComponent.ts → lib/commonjs/DaroRNNativeAdViewNativeComponent.ts} +8 -2
- package/lib/commonjs/LightPopupAd.js +15 -1
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/NativeDaroModule.js +1 -1
- package/lib/commonjs/NativeDaroModule.js.map +1 -1
- package/lib/commonjs/hooks/useLightPopupAd.js +6 -4
- package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -1
- package/lib/commonjs/index.js +121 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +10 -3
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/types/NativeAdViewProps.js +21 -0
- package/lib/commonjs/types/NativeAdViewProps.js.map +1 -1
- package/lib/module/AdBannerView.js +1 -3
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +4 -4
- package/lib/module/AppOpenAd.js.map +1 -1
- package/{src/DaroMAdBannerViewNativeComponent.ts → lib/module/DaroRNAdBannerViewNativeComponent.ts} +5 -2
- package/lib/{commonjs/DaroMNativeAdViewNativeComponent.ts → module/DaroRNNativeAdViewNativeComponent.ts} +8 -2
- package/lib/module/LightPopupAd.js +15 -1
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/NativeDaroModule.js +1 -1
- package/lib/module/NativeDaroModule.js.map +1 -1
- package/lib/module/hooks/useLightPopupAd.js +6 -4
- package/lib/module/hooks/useLightPopupAd.js.map +1 -1
- package/lib/module/index.js +101 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +8 -1
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/types/NativeAdViewProps.js +22 -1
- package/lib/module/types/NativeAdViewProps.js.map +1 -1
- package/lib/typescript/commonjs/plugin/src/index.d.ts +2 -6
- package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +2 -6
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts +2 -6
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts +2 -2
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/{DaroMAdBannerViewNativeComponent.d.ts → DaroRNAdBannerViewNativeComponent.d.ts} +3 -2
- package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/{DaroMNativeAdViewNativeComponent.d.ts → DaroRNNativeAdViewNativeComponent.d.ts} +6 -2
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts +3 -0
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +11 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +79 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +2 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts +15 -0
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts +0 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +9 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/index.d.ts +2 -6
- package/lib/typescript/module/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withAndroid.d.ts +2 -6
- package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withIos.d.ts +2 -6
- package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/module/src/AppOpenAd.d.ts +2 -2
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/module/src/{DaroMAdBannerViewNativeComponent.d.ts → DaroRNAdBannerViewNativeComponent.d.ts} +3 -2
- package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/{DaroMNativeAdViewNativeComponent.d.ts → DaroRNNativeAdViewNativeComponent.d.ts} +6 -2
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/LightPopupAd.d.ts +3 -0
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeDaroModule.d.ts +11 -1
- package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +79 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +2 -0
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdInfo.d.ts +15 -0
- package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdProps.d.ts +0 -1
- package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +9 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +8 -5
- package/plugin/build/index.d.ts +2 -6
- package/plugin/build/index.js +21 -56
- package/plugin/build/withAndroid.d.ts +2 -6
- package/plugin/build/withAndroid.js +48 -90
- package/plugin/build/withIos.d.ts +2 -6
- package/plugin/build/withIos.js +37 -33
- package/react-native-daro.podspec +2 -3
- package/src/AdBannerView.tsx +1 -3
- package/src/AppOpenAd.ts +2 -8
- package/{lib/module/DaroMAdBannerViewNativeComponent.ts → src/DaroRNAdBannerViewNativeComponent.ts} +5 -2
- package/{lib/module/DaroMNativeAdViewNativeComponent.ts → src/DaroRNNativeAdViewNativeComponent.ts} +8 -2
- package/src/LightPopupAd.ts +18 -1
- package/src/NativeDaroModule.ts +18 -2
- package/src/hooks/useLightPopupAd.ts +6 -4
- package/src/index.tsx +136 -0
- package/src/nativeAd/NativeAdView.tsx +22 -1
- package/src/types/AdInfo.ts +17 -0
- package/src/types/AdProps.ts +0 -2
- package/src/types/NativeAdViewProps.ts +10 -0
- package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +0 -23
- package/android/src/main/java/com/daro/reactnative/DaroMAdBannerViewManager.kt +0 -155
- package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +0 -257
- package/android/src/main/java/com/daro/reactnative/impl/DaroMLightPopupModuleImpl.kt +0 -150
- package/ios/DaroMModule+LightPopup.swift +0 -183
- package/ios/Fabric/DaroMAdBannerComponentView.mm +0 -207
- package/ios/Fabric/DaroMNativeAdComponentView.mm +0 -294
- package/ios/Paper/DaroMNativeAdViewManager.swift +0 -22
- package/ios/mediation/admob/DaroMediationDebugger.swift +0 -11
- package/lib/commonjs/types/DaroMMobileAds.js +0 -2
- package/lib/commonjs/types/DaroMMobileAds.js.map +0 -1
- package/lib/module/types/DaroMMobileAds.js +0 -2
- package/lib/module/types/DaroMMobileAds.js.map +0 -1
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts +0 -6
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +0 -1
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts +0 -6
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +0 -1
- package/src/types/DaroMMobileAds.ts +0 -5
- /package/ios/{mediation/admob → Shared}/DaroMediationTypes.swift +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
package com.daro.reactnative.impl
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import androidx.core.graphics.toColorInt
|
|
5
|
+
import com.daro.reactnative.DaroRNModule
|
|
6
|
+
import com.daro.reactnative.event.LightPopupEvent
|
|
7
|
+
import com.daro.reactnative.util.AdInfoUtil
|
|
8
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.ReadableMap
|
|
12
|
+
import droom.daro.core.adunit.DaroLightPopupAdUnit
|
|
13
|
+
import droom.daro.core.listener.DaroLightPopupAdListener
|
|
14
|
+
import droom.daro.core.listener.DaroLightPopupAdLoaderListener
|
|
15
|
+
import droom.daro.core.model.DaroAdDisplayFailError
|
|
16
|
+
import droom.daro.core.model.DaroAdInfo
|
|
17
|
+
import droom.daro.core.model.DaroAdLoadError
|
|
18
|
+
import droom.daro.core.model.DaroLightPopupAd
|
|
19
|
+
import droom.daro.core.model.DaroLightPopupAdOptions
|
|
20
|
+
import droom.daro.loader.DaroLightPopupAdLoader
|
|
21
|
+
|
|
22
|
+
internal class DaroRNLightPopupModuleImpl(
|
|
23
|
+
context: ReactApplicationContext,
|
|
24
|
+
private val getCurrentActivity: () -> Activity?,
|
|
25
|
+
) : DaroRNModule.DaroRNLightPopupModule(context), LifecycleEventListener {
|
|
26
|
+
|
|
27
|
+
private val currentActivity: Activity?
|
|
28
|
+
get() = getCurrentActivity()
|
|
29
|
+
|
|
30
|
+
private val requests = mutableMapOf<Int, LightPopupRequest<DaroLightPopupAd>>()
|
|
31
|
+
private var invalidated = false
|
|
32
|
+
|
|
33
|
+
init { context.addLifecycleEventListener(this) }
|
|
34
|
+
private val optionMap: MutableMap<Int, DaroLightPopupAdOptions> = mutableMapOf()
|
|
35
|
+
|
|
36
|
+
override fun isLightPopupReady(requestId: Int, adUnitId: String, promise: Promise) {
|
|
37
|
+
context.runOnUiQueueThread { promise.resolve(requests[requestId]?.isReady == true) }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override fun loadLightPopup(requestId: Int, adUnitId: String) {
|
|
41
|
+
context.runOnUiQueueThread {
|
|
42
|
+
if (invalidated) return@runOnUiQueueThread
|
|
43
|
+
requests.remove(requestId)?.destroy()
|
|
44
|
+
val loader = DaroLightPopupAdLoader(
|
|
45
|
+
context, DaroLightPopupAdUnit(adUnitId, optionMap[requestId] ?: DaroLightPopupAdOptions())
|
|
46
|
+
)
|
|
47
|
+
val request = LightPopupRequest(loader::destroy, DaroLightPopupAd::destroy)
|
|
48
|
+
requests[requestId] = request
|
|
49
|
+
loader.setListener(object : DaroLightPopupAdLoaderListener {
|
|
50
|
+
override fun onAdLoadSuccess(ad: DaroLightPopupAd, responseInfo: DaroAdInfo) {
|
|
51
|
+
if (!request.accept(ad)) return
|
|
52
|
+
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_LOADED_EVENT,
|
|
53
|
+
AdInfoUtil.getAdInfo(requestId, adUnitId, responseInfo))
|
|
54
|
+
}
|
|
55
|
+
override fun onAdLoadFail(err: DaroAdLoadError) {
|
|
56
|
+
if (!request.active) return
|
|
57
|
+
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_LOAD_FAILED_EVENT,
|
|
58
|
+
AdInfoUtil.getAdLoadFailedInfo(requestId, adUnitId, err))
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
loader.load()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override fun setLightPopupAdConfiguration(
|
|
66
|
+
requestId: Int,
|
|
67
|
+
adUnitId: String,
|
|
68
|
+
parameterMap: ReadableMap,
|
|
69
|
+
) {
|
|
70
|
+
val newOption = DaroLightPopupAdOptions().let {
|
|
71
|
+
it.copy(
|
|
72
|
+
backgroundColor = parameterMap.getString("backgroundColor")?.toColorInt()
|
|
73
|
+
?: it.backgroundColor,
|
|
74
|
+
containerColor = parameterMap.getString("cardViewBackgroundColor")?.toColorInt()
|
|
75
|
+
?: it.containerColor,
|
|
76
|
+
adMarkLabelTextColor = parameterMap.getString("adMarkLabelTextColor")?.toColorInt()
|
|
77
|
+
?: it.adMarkLabelTextColor,
|
|
78
|
+
adMarkLabelBackgroundColor = parameterMap.getString("adMarkLabelBackgroundColor")
|
|
79
|
+
?.toColorInt() ?: it.adMarkLabelBackgroundColor,
|
|
80
|
+
titleColor = parameterMap.getString("titleTextColor")?.toColorInt() ?: it.titleColor,
|
|
81
|
+
bodyColor = parameterMap.getString("bodyTextColor")?.toColorInt() ?: it.bodyColor,
|
|
82
|
+
ctaBackgroundColor = parameterMap.getString("ctaButtonBackgroundColor")?.toColorInt()
|
|
83
|
+
?: it.ctaBackgroundColor,
|
|
84
|
+
ctaTextColor = parameterMap.getString("ctaButtonTextColor")?.toColorInt()
|
|
85
|
+
?: it.ctaTextColor,
|
|
86
|
+
closeButtonText = parameterMap.getString("closeButtonText") ?: it.closeButtonText,
|
|
87
|
+
closeButtonColor = parameterMap.getString("closeButtonTextColor")?.toColorInt()
|
|
88
|
+
?: it.closeButtonColor,
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
context.runOnUiQueueThread {
|
|
93
|
+
if (!invalidated) optionMap[requestId] = newOption
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
override fun showLightPopup(requestId: Int, adUnitId: String) {
|
|
98
|
+
context.runOnUiQueueThread {
|
|
99
|
+
val activity = currentActivity ?: return@runOnUiQueueThread
|
|
100
|
+
val request = requests[requestId] ?: return@runOnUiQueueThread
|
|
101
|
+
val popup = request.takeForPresentation() ?: return@runOnUiQueueThread
|
|
102
|
+
popup.setListener(object : DaroLightPopupAdListener {
|
|
103
|
+
override fun onDismiss(ad: DaroAdInfo) {
|
|
104
|
+
if (!request.ownsPresentation(popup)) return
|
|
105
|
+
request.finishPresentation(popup)
|
|
106
|
+
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_HIDDEN_EVENT,
|
|
107
|
+
AdInfoUtil.getAdInfo(requestId, adUnitId, ad))
|
|
108
|
+
}
|
|
109
|
+
override fun onFailedToShow(ad: DaroAdInfo, error: DaroAdDisplayFailError) {
|
|
110
|
+
if (!request.ownsPresentation(popup)) return
|
|
111
|
+
request.finishPresentation(popup)
|
|
112
|
+
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT,
|
|
113
|
+
AdInfoUtil.getAdDisplayFailedInfo(requestId, adUnitId, ad, error))
|
|
114
|
+
}
|
|
115
|
+
override fun onShown(ad: DaroAdInfo) {
|
|
116
|
+
if (!request.ownsPresentation(popup)) return
|
|
117
|
+
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_DISPLAYED_EVENT,
|
|
118
|
+
AdInfoUtil.getAdInfo(requestId, adUnitId, ad))
|
|
119
|
+
}
|
|
120
|
+
override fun onAdClicked(responseInfo: DaroAdInfo) {
|
|
121
|
+
if (!request.ownsPresentation(popup)) return
|
|
122
|
+
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_CLICKED_EVENT,
|
|
123
|
+
AdInfoUtil.getAdInfo(requestId, adUnitId, responseInfo))
|
|
124
|
+
}
|
|
125
|
+
override fun onAdImpression(responseInfo: DaroAdInfo) {
|
|
126
|
+
if (!request.ownsPresentation(popup)) return
|
|
127
|
+
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED,
|
|
128
|
+
AdInfoUtil.getAdInfo(requestId, adUnitId, responseInfo))
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
popup.show(activity)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
override fun destroyLightPopup(requestId: Int) {
|
|
136
|
+
context.runOnUiQueueThread {
|
|
137
|
+
requests.remove(requestId)?.destroy()
|
|
138
|
+
optionMap.remove(requestId)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
override fun invalidate() {
|
|
143
|
+
context.removeLifecycleEventListener(this)
|
|
144
|
+
context.runOnUiQueueThread {
|
|
145
|
+
invalidated = true
|
|
146
|
+
clearRequests()
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private fun clearRequests() {
|
|
151
|
+
val owned = requests.values.toList()
|
|
152
|
+
requests.clear()
|
|
153
|
+
optionMap.clear()
|
|
154
|
+
owned.forEach { it.destroy() }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
override fun onHostDestroy() {
|
|
158
|
+
// RN configuration changes do not destroy the host Activity; native layout handles rotation.
|
|
159
|
+
context.runOnUiQueueThread { clearRequests() }
|
|
160
|
+
}
|
|
161
|
+
override fun onHostResume() = Unit
|
|
162
|
+
override fun onHostPause() = Unit
|
|
163
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package com.daro.reactnative.impl
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
|
-
import com.daro.reactnative.
|
|
4
|
+
import com.daro.reactnative.DaroRNModule
|
|
5
5
|
import com.daro.reactnative.event.RewardedEvent
|
|
6
6
|
import com.daro.reactnative.util.AdInfoUtil
|
|
7
7
|
import com.facebook.react.bridge.Promise
|
|
@@ -15,10 +15,10 @@ import droom.daro.core.model.DaroAdLoadError
|
|
|
15
15
|
import droom.daro.core.model.DaroRewardedAd
|
|
16
16
|
import droom.daro.loader.DaroRewardedAdLoader
|
|
17
17
|
|
|
18
|
-
internal class
|
|
18
|
+
internal class DaroRNRewardedAdModuleImpl(
|
|
19
19
|
context: ReactApplicationContext,
|
|
20
20
|
private val getCurrentActivity: () -> Activity?,
|
|
21
|
-
) :
|
|
21
|
+
) : DaroRNModule.DaroRNRewardedModule(context) {
|
|
22
22
|
|
|
23
23
|
private val currentActivity: Activity?
|
|
24
24
|
get() = getCurrentActivity()
|
|
@@ -100,7 +100,7 @@ internal class DaroMRewardedAdModuleImpl(
|
|
|
100
100
|
private fun retrieveLoader(requestId: Int, adUnitId: String): DaroRewardedAdLoader {
|
|
101
101
|
return loaderMap[requestId] ?: DaroRewardedAdLoader(
|
|
102
102
|
context,
|
|
103
|
-
DaroRewardedAdUnit(adUnitId
|
|
103
|
+
DaroRewardedAdUnit(adUnitId)
|
|
104
104
|
).also {
|
|
105
105
|
loaderMap[requestId] = it
|
|
106
106
|
it.setListener(
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
package com.daro.reactnative.impl
|
|
2
|
+
|
|
3
|
+
/** Owns one native load and presentation. All access runs on the UI thread. */
|
|
4
|
+
internal class LightPopupRequest<Ad : Any>(
|
|
5
|
+
private val cancelLoad: () -> Unit,
|
|
6
|
+
private val destroyAd: (Ad) -> Unit,
|
|
7
|
+
) {
|
|
8
|
+
var active = true
|
|
9
|
+
private set
|
|
10
|
+
private var loaded: Ad? = null
|
|
11
|
+
private var presented: Ad? = null
|
|
12
|
+
val isReady: Boolean get() = active && loaded != null && presented == null
|
|
13
|
+
|
|
14
|
+
fun accept(ad: Ad): Boolean {
|
|
15
|
+
if (!active) {
|
|
16
|
+
destroyAd(ad)
|
|
17
|
+
return false
|
|
18
|
+
}
|
|
19
|
+
loaded?.let(destroyAd)
|
|
20
|
+
loaded = ad
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fun takeForPresentation(): Ad? {
|
|
25
|
+
if (!isReady) return null
|
|
26
|
+
return loaded?.also {
|
|
27
|
+
loaded = null
|
|
28
|
+
presented = it
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fun ownsPresentation(ad: Ad): Boolean = active && presented === ad
|
|
33
|
+
|
|
34
|
+
fun finishPresentation(ad: Ad) {
|
|
35
|
+
if (!ownsPresentation(ad)) return
|
|
36
|
+
presented = null
|
|
37
|
+
destroyAd(ad)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fun destroy() {
|
|
41
|
+
if (!active) return
|
|
42
|
+
active = false
|
|
43
|
+
val ready = loaded
|
|
44
|
+
val showing = presented
|
|
45
|
+
loaded = null
|
|
46
|
+
presented = null
|
|
47
|
+
cancelLoad()
|
|
48
|
+
ready?.let(destroyAd)
|
|
49
|
+
showing?.let(destroyAd)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -8,10 +8,22 @@ import droom.daro.core.model.DaroAdLoadError
|
|
|
8
8
|
import droom.daro.core.model.DaroRewardedAd
|
|
9
9
|
|
|
10
10
|
internal object AdInfoUtil {
|
|
11
|
+
// 모듈 경로(전면·리워드·앱오픈·라이트팝업)와 뷰 경로(배너·네이티브)가 **둘 다 여기를
|
|
12
|
+
// 지난다.** 그래서 귀속을 여기 한 번만 실으면 모든 포맷이 같이 얻는다.
|
|
11
13
|
fun getAdInfo(adUnitId: String, ad: DaroAdInfo): WritableMap {
|
|
12
14
|
val adInfo = Arguments.createMap()
|
|
13
15
|
adInfo.putString("adUnitId", adUnitId)
|
|
14
16
|
adInfo.putInt("latencyMillis", ad.latency)
|
|
17
|
+
// SDK 가 정한 어휘를 **그대로** 넘긴다 — 래퍼에서 매핑하지 않는다. 발행 tarball 이
|
|
18
|
+
// android/ios 를 소스로 싣기 때문에 여기 매핑을 두면 그대로 읽힌다.
|
|
19
|
+
//
|
|
20
|
+
// **공개 표면인 DaroAdInfo.mediationPlatform 을 읽는다** (DARO-1587). enum 의
|
|
21
|
+
// mediationPlatformName 은 internal 로 닫혔고, 그쪽은 서버 payload 용 벤더 이름
|
|
22
|
+
// (admob/applovin)이라 애초에 소비자에게 나가면 안 되는 값이다. iOS 브릿지도
|
|
23
|
+
// 같은 이름의 프로퍼티를 읽는다 — 두 플랫폼이 같은 모양이다.
|
|
24
|
+
adInfo.putString("mediationPlatform", ad.mediationPlatform)
|
|
25
|
+
// 벤더 어휘. 정규화하지 않는다 (AdMob adSourceName / AppLovin networkName).
|
|
26
|
+
adInfo.putString("adNetwork", ad.adNetwork)
|
|
15
27
|
|
|
16
28
|
return adInfo
|
|
17
29
|
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
package com.daro.reactnative.util
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.applovin.sdk.AppLovinSdk
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
6
|
+
import com.facebook.react.bridge.WritableArray
|
|
7
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
|
+
import com.google.android.gms.ads.MobileAds
|
|
9
|
+
import com.google.android.gms.ads.VersionInfo
|
|
10
|
+
import com.google.android.gms.ads.initialization.AdapterStatus.State
|
|
11
|
+
import com.google.android.gms.ads.mediation.Adapter
|
|
12
|
+
import droom.daro.core.model.DaroMediationType
|
|
13
|
+
import droom.daro.core.routing.MediationReadiness
|
|
14
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
15
|
+
|
|
16
|
+
// daro-android-qa 의 MediationStatusProbe 와 같은 축 — 초기화 판정은 라우팅이 쓰는
|
|
17
|
+
// SDK 값(@Keep MediationReadiness)을 그대로 읽고, 서브네트워크 어댑터 목록은 SDK 가
|
|
18
|
+
// 갖지 않으므로 벤더에 직접 묻는다. 여기서 다시 추론하면 화면과 실제 라우팅이 갈린다.
|
|
19
|
+
object DaroQaProbe {
|
|
20
|
+
|
|
21
|
+
// GMA 의 adapterStatusMap 은 초기화된 것만 담는다 — 탑재 여부는 클래스로,
|
|
22
|
+
// 버전은 어댑터에게, 초기화 상태는 맵에서 따로 읽는다.
|
|
23
|
+
private val ADMOB_ADAPTERS = listOf(
|
|
24
|
+
"AppLovin" to "com.google.ads.mediation.applovin.AppLovinMediationAdapter",
|
|
25
|
+
"DT Exchange" to "com.google.ads.mediation.fyber.FyberMediationAdapter",
|
|
26
|
+
"InMobi" to "com.google.ads.mediation.inmobi.InMobiMediationAdapter",
|
|
27
|
+
"LINE" to "com.google.ads.mediation.line.LineMediationAdapter",
|
|
28
|
+
"Meta" to "com.google.ads.mediation.facebook.FacebookMediationAdapter",
|
|
29
|
+
"Mintegral" to "com.google.ads.mediation.mintegral.MintegralMediationAdapter",
|
|
30
|
+
"Moloco" to "com.google.ads.mediation.moloco.MolocoMediationAdapter",
|
|
31
|
+
"Pangle" to "com.google.ads.mediation.pangle.PangleMediationAdapter",
|
|
32
|
+
"PubMatic" to "com.google.ads.mediation.pubmatic.PubMaticMediationAdapter",
|
|
33
|
+
"Unity Ads" to "com.google.ads.mediation.unity.UnityMediationAdapter",
|
|
34
|
+
"Vungle" to "com.google.ads.mediation.vungle.VungleMediationAdapter",
|
|
35
|
+
"ironSource" to "com.google.ads.mediation.ironsource.IronSourceMediationAdapter",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
fun mediationStatuses(): WritableArray {
|
|
39
|
+
val statuses = Arguments.createArray()
|
|
40
|
+
listOf(DaroMediationType.Daro, DaroMediationType.DaroM).forEach { mediation ->
|
|
41
|
+
val ready = MediationReadiness.isReady(mediation)
|
|
42
|
+
statuses.pushMap(
|
|
43
|
+
Arguments.createMap().apply {
|
|
44
|
+
// **공개 어휘(publicName)를 쓴다** — `daroa`/`darom` (DARO-1587).
|
|
45
|
+
// 이 값은 getMediationStatuses() 로 소비자에게 나가므로 DaroAdInfo.mediationPlatform
|
|
46
|
+
// 과 같은 어휘여야 한다. 갈리면 한 앱 안에서 두 이름이 돌아다닌다.
|
|
47
|
+
// iOS 는 DaroMediationState 가 provider.publicName 을 쓰는 것과 같은 자리다.
|
|
48
|
+
putString("mediationPlatform", mediation.publicName)
|
|
49
|
+
putBoolean("isReady", ready == true)
|
|
50
|
+
putBoolean("hasFailed", ready == false)
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
return statuses
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fun adapterInventory(context: Context): WritableMap =
|
|
58
|
+
Arguments.createMap().apply {
|
|
59
|
+
putArray("admob", adMobAdapters())
|
|
60
|
+
putArray("applovin", appLovinAdapters(context))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private fun adapterRow(name: String, detail: String, isReady: Boolean): WritableMap =
|
|
64
|
+
Arguments.createMap().apply {
|
|
65
|
+
putString("name", name)
|
|
66
|
+
putString("detail", detail)
|
|
67
|
+
putBoolean("isReady", isReady)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private fun adMobAdapters(): WritableArray {
|
|
71
|
+
val initStates = runCatching {
|
|
72
|
+
MobileAds.getInitializationStatus()?.adapterStatusMap.orEmpty()
|
|
73
|
+
}.getOrDefault(emptyMap())
|
|
74
|
+
|
|
75
|
+
val rows = Arguments.createArray()
|
|
76
|
+
ADMOB_ADAPTERS.forEach { (name, className) ->
|
|
77
|
+
val version = adapterVersion(className)
|
|
78
|
+
val state = initStates[className]?.initializationState
|
|
79
|
+
rows.pushMap(
|
|
80
|
+
adapterRow(
|
|
81
|
+
name = name,
|
|
82
|
+
detail = when {
|
|
83
|
+
version == null -> "미탑재"
|
|
84
|
+
state == State.READY -> "$version · READY"
|
|
85
|
+
state == State.NOT_READY -> "$version · NOT_READY"
|
|
86
|
+
else -> "$version · 미초기화"
|
|
87
|
+
},
|
|
88
|
+
isReady = version != null,
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
return rows
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 탑재된 어댑터의 버전은 바이너리가 정하므로 안 바뀐다 — 호출마다 12종을
|
|
96
|
+
// Class.forName + newInstance 하면 직렬화된 NativeModules 스레드를 잡아먹는다.
|
|
97
|
+
//
|
|
98
|
+
// **성공과 '진짜 미탑재'만 캐시한다.** 실패를 전부 캐시하면 다른 이유로 한 번 실패한
|
|
99
|
+
// 프로브가(벤더 SDK 로드 전 생성자 예외·클래스로더 문제) 프로세스 수명 동안 가짜
|
|
100
|
+
// '미탑재'로 굳는다 — 이 프로브가 배제하려던 오신호다. 반대로 아무것도 캐시하지
|
|
101
|
+
// 않으면 없는 어댑터마다 매 호출 ClassNotFoundException 을 던져(직렬 브리지 스레드다)
|
|
102
|
+
// 펼칠 때마다 12번 반복한다. 클래스 부재는 바이너리가 정하므로 그것만 캐시한다.
|
|
103
|
+
private val adapterVersionCache = ConcurrentHashMap<String, String>()
|
|
104
|
+
private val absentAdapters = ConcurrentHashMap.newKeySet<String>()
|
|
105
|
+
|
|
106
|
+
private fun adapterVersion(className: String): String? {
|
|
107
|
+
adapterVersionCache[className]?.let { return it }
|
|
108
|
+
if (className in absentAdapters) {
|
|
109
|
+
return null
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return try {
|
|
113
|
+
val adapter = Class.forName(className).getDeclaredConstructor().newInstance() as Adapter
|
|
114
|
+
adapter.versionInfo.format().also { adapterVersionCache[className] = it }
|
|
115
|
+
} catch (ignored: ClassNotFoundException) {
|
|
116
|
+
// 바이너리에 없다 — 이 프로세스에서 생길 리 없으니 기억한다.
|
|
117
|
+
absentAdapters.add(className)
|
|
118
|
+
null
|
|
119
|
+
} catch (ignored: Throwable) {
|
|
120
|
+
// 그 밖의 실패는 일시적일 수 있다 — 다음 조회에서 다시 시도한다.
|
|
121
|
+
null
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// GMA 는 4자리 어댑터 버전을 3필드에 담는다 — micro 가 "patch*100 + build" 다.
|
|
126
|
+
private fun VersionInfo.format() =
|
|
127
|
+
"$majorVersion.$minorVersion.${microVersion / 100}.${microVersion % 100}"
|
|
128
|
+
|
|
129
|
+
// MAX 는 어댑터별 초기화 상태를 내주지 않는다 — 실린 어댑터와 버전만 안다.
|
|
130
|
+
private fun appLovinAdapters(context: Context): WritableArray {
|
|
131
|
+
val rows = Arguments.createArray()
|
|
132
|
+
runCatching {
|
|
133
|
+
AppLovinSdk.getInstance(context).availableMediatedNetworks
|
|
134
|
+
.sortedBy { it.name }
|
|
135
|
+
.forEach {
|
|
136
|
+
rows.pushMap(
|
|
137
|
+
adapterRow(
|
|
138
|
+
name = it.name,
|
|
139
|
+
detail = it.adapterVersion.ifBlank { "미탑재" },
|
|
140
|
+
isReady = it.adapterVersion.isNotBlank(),
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return rows
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -2,7 +2,7 @@ package com.daro.reactnative.util
|
|
|
2
2
|
|
|
3
3
|
import android.view.View
|
|
4
4
|
import com.daro.reactnative.event.AdViewEvent
|
|
5
|
-
import com.daro.reactnative.event.
|
|
5
|
+
import com.daro.reactnative.event.DaroRNEvent
|
|
6
6
|
import com.facebook.react.bridge.ReactContext
|
|
7
7
|
import com.facebook.react.bridge.WritableMap
|
|
8
8
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
@@ -11,7 +11,7 @@ import com.facebook.react.uimanager.events.Event
|
|
|
11
11
|
|
|
12
12
|
internal object EventEmitterUtil {
|
|
13
13
|
// React Native Bridge
|
|
14
|
-
fun sendReactNativeEvent(reactContext: ReactContext, event:
|
|
14
|
+
fun sendReactNativeEvent(reactContext: ReactContext, event: DaroRNEvent, params: WritableMap?) {
|
|
15
15
|
reactContext
|
|
16
16
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
17
17
|
.emit(event.value, params)
|
|
@@ -22,7 +22,7 @@ import droom.daro.view.DaroAdViewListener
|
|
|
22
22
|
import droom.daro.view.DaroBannerAdView
|
|
23
23
|
|
|
24
24
|
@SuppressLint("ViewConstructor")
|
|
25
|
-
class
|
|
25
|
+
class DaroRNAdBannerViewContainer(val context: ReactContext) : ReactViewGroup(context),
|
|
26
26
|
DaroAdViewListener {
|
|
27
27
|
private companion object {
|
|
28
28
|
private const val MAX_PENDING_LOAD_RETRIES = 10
|
|
@@ -59,7 +59,7 @@ class DaroMAdBannerViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
59
59
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
60
60
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
61
61
|
)
|
|
62
|
-
this@
|
|
62
|
+
this@DaroRNAdBannerViewContainer.addView(this)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
layoutAdView()
|
|
@@ -92,7 +92,6 @@ class DaroMAdBannerViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
92
92
|
context,
|
|
93
93
|
DaroBannerAdUnit(
|
|
94
94
|
key = adUnitId,
|
|
95
|
-
placement = adUnitId,
|
|
96
95
|
bannerSize = adSize!!,
|
|
97
96
|
)
|
|
98
97
|
).also { view ->
|
|
@@ -15,6 +15,7 @@ import androidx.core.view.children
|
|
|
15
15
|
import com.daro.reactnative.event.AdViewEvent
|
|
16
16
|
import com.daro.reactnative.util.AdInfoUtil
|
|
17
17
|
import com.daro.reactnative.util.EventEmitterUtil.sendNativeViewEvent
|
|
18
|
+
import com.facebook.react.bridge.Arguments
|
|
18
19
|
import com.facebook.react.bridge.ReactContext
|
|
19
20
|
import com.facebook.react.views.text.ReactTextView
|
|
20
21
|
import com.facebook.react.views.view.ReactViewGroup
|
|
@@ -24,6 +25,7 @@ import droom.daro.core.model.DaroAdLoadError
|
|
|
24
25
|
import droom.daro.core.model.DaroNativeAdBinder
|
|
25
26
|
import droom.daro.core.model.DaroNativeAdChoicePlacement
|
|
26
27
|
import droom.daro.core.model.DaroViewAd
|
|
28
|
+
import droom.daro.core.model.NativeAdAssetType
|
|
27
29
|
import droom.daro.view.DaroAdViewListener
|
|
28
30
|
import droom.daro.view.DaroNativeAdView
|
|
29
31
|
import kotlin.math.min
|
|
@@ -31,7 +33,7 @@ import kotlin.math.roundToInt
|
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
@SuppressLint("ViewConstructor")
|
|
34
|
-
class
|
|
36
|
+
class DaroRNAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(context),
|
|
35
37
|
DaroAdViewListener {
|
|
36
38
|
|
|
37
39
|
private companion object {
|
|
@@ -116,7 +118,7 @@ class DaroMAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
116
118
|
adView = view
|
|
117
119
|
|
|
118
120
|
if (view.parent == null) {
|
|
119
|
-
this@
|
|
121
|
+
this@DaroRNAdNativeViewContainer.addView(view)
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
view.loadAd()
|
|
@@ -134,7 +136,6 @@ class DaroMAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
134
136
|
context,
|
|
135
137
|
DaroNativeAdUnit(
|
|
136
138
|
key = adUnitId,
|
|
137
|
-
placement = adUnitId,
|
|
138
139
|
)
|
|
139
140
|
).also { view ->
|
|
140
141
|
view.setAdBinder(
|
|
@@ -195,6 +196,24 @@ class DaroMAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
|
|
199
|
+
override fun onNativeAdAssetLoaded(assetTypes: Set<NativeAdAssetType>) {
|
|
200
|
+
if (isDestroyed) return
|
|
201
|
+
val values = Arguments.createArray()
|
|
202
|
+
assetTypes.forEach { type ->
|
|
203
|
+
values.pushString(when (type.name) {
|
|
204
|
+
"TITLE" -> "title"
|
|
205
|
+
"BODY" -> "body"
|
|
206
|
+
"ICON" -> "icon"
|
|
207
|
+
"MEDIA" -> "media"
|
|
208
|
+
"CALL_TO_ACTION" -> "callToAction"
|
|
209
|
+
"ADVERTISER" -> "advertiser"
|
|
210
|
+
else -> type.name.lowercase()
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
sendNativeViewEvent(context, AdViewEvent.ON_NATIVE_ASSETS_LOADED,
|
|
214
|
+
Arguments.createMap().apply { putArray("assetTypes", values) })
|
|
215
|
+
}
|
|
216
|
+
|
|
198
217
|
override fun onAdLoadSuccess(
|
|
199
218
|
ad: DaroViewAd,
|
|
200
219
|
adInfo: DaroAdInfo,
|
|
@@ -253,7 +272,7 @@ class DaroMAdNativeViewContainer(val context: ReactContext) : ReactViewGroup(con
|
|
|
253
272
|
}
|
|
254
273
|
}
|
|
255
274
|
|
|
256
|
-
private inner class LoadAdTask(private val nativeAdView:
|
|
275
|
+
private inner class LoadAdTask(private val nativeAdView: DaroRNAdNativeViewContainer) :
|
|
257
276
|
Runnable {
|
|
258
277
|
|
|
259
278
|
override fun run() {
|
package/android/src/newarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt}
RENAMED
|
@@ -2,5 +2,5 @@ package com.daro.reactnative
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
4
|
|
|
5
|
-
abstract class
|
|
5
|
+
abstract class DaroRNModuleSpec(reactContext: ReactApplicationContext) :
|
|
6
6
|
NativeDaroModuleSpec(reactContext)
|
package/android/src/oldarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt}
RENAMED
|
@@ -6,10 +6,10 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
|
6
6
|
import com.facebook.react.bridge.ReactMethod
|
|
7
7
|
import com.facebook.react.bridge.ReadableMap
|
|
8
8
|
|
|
9
|
-
abstract class
|
|
9
|
+
abstract class DaroRNModuleSpec(reactContext: ReactApplicationContext) :
|
|
10
10
|
ReactContextBaseJavaModule(reactContext) {
|
|
11
11
|
|
|
12
|
-
override fun getName(): String =
|
|
12
|
+
override fun getName(): String = DaroRNModule.NAME
|
|
13
13
|
|
|
14
14
|
protected abstract fun getTypedExportedConstants(): MutableMap<String, Any>
|
|
15
15
|
|
|
@@ -30,9 +30,39 @@ abstract class DaroMModuleSpec(reactContext: ReactApplicationContext) :
|
|
|
30
30
|
@ReactMethod
|
|
31
31
|
abstract fun setUserId(userId: String, promise: Promise)
|
|
32
32
|
|
|
33
|
+
@ReactMethod
|
|
34
|
+
abstract fun setGdpr(status: String, consentString: String, promise: Promise)
|
|
35
|
+
|
|
36
|
+
@ReactMethod
|
|
37
|
+
abstract fun setCcpa(status: String, consentString: String, promise: Promise)
|
|
38
|
+
|
|
39
|
+
@ReactMethod
|
|
40
|
+
abstract fun setCoppa(status: String, promise: Promise)
|
|
41
|
+
|
|
33
42
|
@ReactMethod
|
|
34
43
|
abstract fun showMediationDebugger(promise: Promise)
|
|
35
44
|
|
|
45
|
+
// QA 표면 — newarch 는 NativeDaroModule.ts 에서 코드젠으로 생기지만 oldarch 는 이
|
|
46
|
+
// 손 스펙이 정본이다. 스펙에 메서드를 더할 때 여기도 같이 더하지 않으면 oldarch
|
|
47
|
+
// 소비자에서 "overrides nothing" 으로 컴파일이 깨진다 (example 은 newarch 라 안 보인다).
|
|
48
|
+
@ReactMethod
|
|
49
|
+
abstract fun showMediationDebuggerFor(mediation: String, promise: Promise)
|
|
50
|
+
|
|
51
|
+
@ReactMethod
|
|
52
|
+
abstract fun getSdkVersion(promise: Promise)
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
abstract fun getMediationStatuses(promise: Promise)
|
|
56
|
+
|
|
57
|
+
@ReactMethod
|
|
58
|
+
abstract fun getMediationWeights(promise: Promise)
|
|
59
|
+
|
|
60
|
+
@ReactMethod
|
|
61
|
+
abstract fun getAdapterInventory(promise: Promise)
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
abstract fun getIntegrationKeyInfo(promise: Promise)
|
|
65
|
+
|
|
36
66
|
@ReactMethod
|
|
37
67
|
abstract fun isInterstitialReady(requestId: Double, adUnitId: String, promise: Promise)
|
|
38
68
|
|
|
@@ -66,11 +96,13 @@ abstract class DaroMModuleSpec(reactContext: ReactApplicationContext) :
|
|
|
66
96
|
abstract fun showAppOpenAd(
|
|
67
97
|
requestId: Double,
|
|
68
98
|
adUnitId: String,
|
|
69
|
-
placement: String?,
|
|
70
99
|
customData: String?,
|
|
71
100
|
promise: Promise,
|
|
72
101
|
)
|
|
73
102
|
|
|
103
|
+
@ReactMethod
|
|
104
|
+
abstract fun destroyLightPopup(requestId: Double, adUnitId: String)
|
|
105
|
+
|
|
74
106
|
@ReactMethod
|
|
75
107
|
abstract fun isLightPopupReady(requestId: Double, adUnitId: String, promise: Promise)
|
|
76
108
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package com.daro.reactnative.impl
|
|
2
|
+
|
|
3
|
+
import org.junit.Assert.*
|
|
4
|
+
import org.junit.Test
|
|
5
|
+
|
|
6
|
+
class LightPopupRequestTest {
|
|
7
|
+
private class Ad(var destroyed: Int = 0)
|
|
8
|
+
|
|
9
|
+
@Test fun disposeCancelsLoaderAndRejectsLateDelivery() {
|
|
10
|
+
var cancellations = 0
|
|
11
|
+
val request = LightPopupRequest({ cancellations++ }, { ad: Ad -> ad.destroyed++ })
|
|
12
|
+
request.destroy()
|
|
13
|
+
request.destroy()
|
|
14
|
+
val late = Ad()
|
|
15
|
+
assertFalse(request.accept(late))
|
|
16
|
+
assertEquals(1, late.destroyed)
|
|
17
|
+
assertEquals(1, cancellations)
|
|
18
|
+
assertNull(request.takeForPresentation())
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Test fun showingConsumesReadinessButRetainsOwnershipUntilDismissal() {
|
|
22
|
+
val request = LightPopupRequest({}, { ad: Ad -> ad.destroyed++ })
|
|
23
|
+
val ad = Ad()
|
|
24
|
+
assertTrue(request.accept(ad))
|
|
25
|
+
assertTrue(request.isReady)
|
|
26
|
+
assertSame(ad, request.takeForPresentation())
|
|
27
|
+
assertFalse(request.isReady)
|
|
28
|
+
assertNull(request.takeForPresentation())
|
|
29
|
+
assertTrue(request.ownsPresentation(ad))
|
|
30
|
+
request.finishPresentation(ad)
|
|
31
|
+
request.finishPresentation(ad)
|
|
32
|
+
assertFalse(request.ownsPresentation(ad))
|
|
33
|
+
assertEquals(1, ad.destroyed)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Test fun disposalDestroysPresentedAdAndRevokesEventsBeforeCleanup() {
|
|
37
|
+
lateinit var request: LightPopupRequest<Ad>
|
|
38
|
+
val ad = Ad()
|
|
39
|
+
request = LightPopupRequest({}, { value ->
|
|
40
|
+
assertFalse(request.ownsPresentation(value))
|
|
41
|
+
value.destroyed++
|
|
42
|
+
})
|
|
43
|
+
request.accept(ad)
|
|
44
|
+
request.takeForPresentation()
|
|
45
|
+
request.destroy()
|
|
46
|
+
assertEquals(1, ad.destroyed)
|
|
47
|
+
assertFalse(request.active)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Test fun staleDismissCannotReleaseAnotherAd() {
|
|
51
|
+
val request = LightPopupRequest({}, { ad: Ad -> ad.destroyed++ })
|
|
52
|
+
val stale = Ad()
|
|
53
|
+
val current = Ad()
|
|
54
|
+
request.accept(stale)
|
|
55
|
+
request.accept(current)
|
|
56
|
+
request.takeForPresentation()
|
|
57
|
+
request.finishPresentation(stale)
|
|
58
|
+
assertTrue(request.ownsPresentation(current))
|
|
59
|
+
assertEquals(0, current.destroyed)
|
|
60
|
+
assertEquals(1, stale.destroyed)
|
|
61
|
+
}
|
|
62
|
+
}
|