react-native-daro 2.0.7 → 2.0.9-rc.1
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 -2
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/daro/reactnative/DaroRNAdBannerViewManager.kt +8 -3
- package/android/src/main/java/com/daro/reactnative/DaroRNAdNativeViewManager.kt +8 -3
- package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +76 -34
- package/android/src/main/java/com/daro/reactnative/event/DaroRNEvent.kt +8 -0
- package/android/src/main/java/com/daro/reactnative/impl/DaroRNInterstitialModuleImpl.kt +13 -13
- package/android/src/main/java/com/daro/reactnative/impl/DaroRNLightPopupModuleImpl.kt +12 -12
- package/android/src/main/java/com/daro/reactnative/impl/DaroRNPreloadModuleImpl.kt +77 -0
- package/android/src/main/java/com/daro/reactnative/impl/DaroRNRewardedAdModuleImpl.kt +14 -14
- package/android/src/main/java/com/daro/reactnative/preload/DaroRNPreloadRegistry.kt +57 -0
- package/android/src/main/java/com/daro/reactnative/util/AdInfoUtil.kt +27 -16
- package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +3 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroRNAdBannerViewContainer.kt +36 -15
- package/android/src/main/java/com/daro/reactnative/view/DaroRNAdNativeViewContainer.kt +36 -15
- package/android/src/oldarch/java/com/daro/reactnative/DaroRNModuleSpec.kt +28 -14
- package/android/src/test/java/com/daro/reactnative/preload/DaroRNPreloadRegistryTest.kt +65 -0
- package/android/src/test/java/com/daro/reactnative/view/DaroMediaViewTest.kt +45 -0
- package/android/src/test/java/com/daro/reactnative/view/DaroRNPreloadFirstLoadTest.kt +160 -0
- package/ios/DaroRNModule+AppOpen.swift +9 -9
- package/ios/DaroRNModule+Interstitial.swift +9 -9
- package/ios/DaroRNModule+LightPopup.swift +13 -13
- package/ios/DaroRNModule+Preload.swift +122 -0
- package/ios/DaroRNModule+Rewarded.swift +14 -14
- package/ios/DaroRNModule.mm +20 -14
- package/ios/DaroRNModule.swift +6 -1
- package/ios/Fabric/DaroRNAdBannerComponentView.mm +12 -7
- package/ios/Fabric/DaroRNNativeAdComponentView.mm +12 -7
- package/ios/Paper/DaroRNAdBannerViewManager.m +2 -1
- package/ios/Paper/DaroRNNativeAdViewManager.m +2 -1
- package/ios/Shared/DaroRNBannerAdView.swift +23 -9
- package/ios/Shared/DaroRNNativeAdView.swift +77 -46
- package/ios/Shared/DaroRNPreloadRegistry.swift +54 -0
- package/lib/commonjs/AdBannerView.js +4 -2
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AdPreload.js +105 -0
- package/lib/commonjs/AdPreload.js.map +1 -0
- package/lib/commonjs/AppOpenAd.js +22 -22
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/DaroRNAdBannerViewNativeComponent.ts +5 -3
- package/lib/commonjs/DaroRNNativeAdViewNativeComponent.ts +5 -3
- package/lib/commonjs/InterstitialAd.js +24 -24
- package/lib/commonjs/InterstitialAd.js.map +1 -1
- package/lib/commonjs/LightPopupAd.js +27 -27
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/NativeDaroModule.js.map +1 -1
- package/lib/commonjs/RewardedAd.js +22 -22
- package/lib/commonjs/RewardedAd.js.map +1 -1
- package/lib/commonjs/hooks/useAdPreload.js +61 -0
- package/lib/commonjs/hooks/useAdPreload.js.map +1 -0
- package/lib/commonjs/hooks/useInterstitialAd.js +6 -6
- package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -1
- package/lib/commonjs/hooks/useLightPopupAd.js +5 -5
- package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -1
- package/lib/commonjs/hooks/useRewardedAd.js +6 -6
- package/lib/commonjs/hooks/useRewardedAd.js.map +1 -1
- package/lib/commonjs/index.js +37 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +4 -2
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/types/NativeAdViewProps.js.map +1 -1
- package/lib/module/AdBannerView.js +4 -2
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AdPreload.js +98 -0
- package/lib/module/AdPreload.js.map +1 -0
- package/lib/module/AppOpenAd.js +22 -22
- package/lib/module/AppOpenAd.js.map +1 -1
- package/lib/module/DaroRNAdBannerViewNativeComponent.ts +5 -3
- package/lib/module/DaroRNNativeAdViewNativeComponent.ts +5 -3
- package/lib/module/InterstitialAd.js +24 -24
- package/lib/module/InterstitialAd.js.map +1 -1
- package/lib/module/LightPopupAd.js +27 -27
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/NativeDaroModule.js.map +1 -1
- package/lib/module/RewardedAd.js +22 -22
- package/lib/module/RewardedAd.js.map +1 -1
- package/lib/module/hooks/useAdPreload.js +56 -0
- package/lib/module/hooks/useAdPreload.js.map +1 -0
- package/lib/module/hooks/useInterstitialAd.js +6 -6
- package/lib/module/hooks/useInterstitialAd.js.map +1 -1
- package/lib/module/hooks/useLightPopupAd.js +5 -5
- package/lib/module/hooks/useLightPopupAd.js.map +1 -1
- package/lib/module/hooks/useRewardedAd.js +6 -6
- package/lib/module/hooks/useRewardedAd.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +4 -2
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/types/NativeAdViewProps.js.map +1 -1
- package/lib/typescript/commonjs/src/AdBannerView.d.ts +1 -0
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AdPreload.d.ts +62 -0
- package/lib/typescript/commonjs/src/AdPreload.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts +8 -8
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts +4 -3
- package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts +4 -3
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts +8 -8
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts +9 -9
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +19 -14
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/RewardedAd.d.ts +8 -8
- package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useAdPreload.d.ts +19 -0
- package/lib/typescript/commonjs/src/hooks/useAdPreload.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +1 -1
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +1 -1
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +1 -1
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +1 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +6 -0
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts +1 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +6 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/module/src/AdBannerView.d.ts +1 -0
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/module/src/AdPreload.d.ts +62 -0
- package/lib/typescript/module/src/AdPreload.d.ts.map +1 -0
- package/lib/typescript/module/src/AppOpenAd.d.ts +8 -8
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts +4 -3
- package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts +4 -3
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/InterstitialAd.d.ts +8 -8
- package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/module/src/LightPopupAd.d.ts +9 -9
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeDaroModule.d.ts +19 -14
- package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -1
- package/lib/typescript/module/src/RewardedAd.d.ts +8 -8
- package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useAdPreload.d.ts +19 -0
- package/lib/typescript/module/src/hooks/useAdPreload.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +1 -1
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +1 -1
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +1 -1
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +1 -0
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +6 -0
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdInfo.d.ts +2 -2
- package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdProps.d.ts +1 -1
- package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +6 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/build/withAndroid.js +2 -2
- package/react-native-daro.podspec +1 -1
- package/src/AdBannerView.tsx +4 -2
- package/src/AdPreload.ts +141 -0
- package/src/AppOpenAd.ts +21 -21
- package/src/DaroRNAdBannerViewNativeComponent.ts +5 -3
- package/src/DaroRNNativeAdViewNativeComponent.ts +5 -3
- package/src/InterstitialAd.ts +23 -23
- package/src/LightPopupAd.ts +26 -26
- package/src/NativeDaroModule.ts +31 -14
- package/src/RewardedAd.ts +21 -21
- package/src/hooks/useAdPreload.ts +82 -0
- package/src/hooks/useInterstitialAd.ts +6 -6
- package/src/hooks/useLightPopupAd.ts +5 -5
- package/src/hooks/useRewardedAd.ts +6 -6
- package/src/index.tsx +16 -0
- package/src/nativeAd/NativeAdView.tsx +4 -2
- package/src/types/AdBannerViewProps.ts +6 -0
- package/src/types/AdInfo.ts +2 -2
- package/src/types/AdProps.ts +1 -1
- package/src/types/NativeAdViewProps.ts +6 -0
package/README.md
CHANGED
|
@@ -58,6 +58,6 @@ If an Android Release build fails in a SafeDK or manifest task with a
|
|
|
58
58
|
Configuration Cache error, set Boolean `android.safedkConfigurationCacheWorkaround`
|
|
59
59
|
to `true` in the plugin options and rerun prebuild or EAS Build. `false` disables
|
|
60
60
|
the workaround; omission preserves the existing Gradle value. Generated Android
|
|
61
|
-
builds use SDK 2.0.
|
|
61
|
+
builds use SDK 2.1.0-rc.1 and Gradle plugin 2.0.5. React Native CLI projects can set
|
|
62
62
|
`daro.safedkConfigurationCacheWorkaround=true` in `android/gradle.properties`
|
|
63
|
-
after updating the Gradle plugin to 2.0.
|
|
63
|
+
after updating the Gradle plugin to 2.0.5.
|
package/android/build.gradle
CHANGED
|
@@ -33,7 +33,7 @@ apply plugin: "kotlin-android"
|
|
|
33
33
|
apply plugin: "com.facebook.react"
|
|
34
34
|
|
|
35
35
|
// 통합 daro-sdk 는 AdMob·MAX 미디에이션을 한 아티팩트에 담는다 — 빌드타임 분기가 없다.
|
|
36
|
-
def daroSdkDependency = "so.daro:daro-sdk:2.0.
|
|
36
|
+
def daroSdkDependency = "so.daro:daro-sdk:2.1.0-rc.1"
|
|
37
37
|
def isNewArchitectureEnabled =
|
|
38
38
|
(project.hasProperty("newArchEnabled") && project.property("newArchEnabled").toString().toBoolean()) ||
|
|
39
39
|
(project.hasProperty("react.newArchEnabled") && project.property("react.newArchEnabled").toString().toBoolean())
|
|
@@ -83,6 +83,8 @@ dependencies {
|
|
|
83
83
|
testImplementation daroSdkDependency
|
|
84
84
|
testImplementation "org.robolectric:robolectric:4.16.1"
|
|
85
85
|
testImplementation "io.mockk:mockk:1.13.17"
|
|
86
|
+
// SDK 뷰의 생성자를 건너뛰는 데 쓴다. mockk 의 mockkConstructor 는 Android 뷰 계층에서 테스트 JVM 을 멈춘다.
|
|
87
|
+
testImplementation "org.mockito:mockito-core:5.12.0"
|
|
86
88
|
// Match the existing RN runtime lifecycle floor; daro-sdk supplies runtime
|
|
87
89
|
// classes but its implementation dependencies are not on our compile path.
|
|
88
90
|
compileOnly "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
|
|
@@ -77,9 +77,9 @@ class DaroRNAdBannerViewManager : SimpleViewManager<DaroRNAdBannerViewContainer>
|
|
|
77
77
|
view.setAdVisibility(isVisible)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
@ReactProp(name = "
|
|
81
|
-
override fun
|
|
82
|
-
view.
|
|
80
|
+
@ReactProp(name = "adUnitKey")
|
|
81
|
+
override fun setAdUnitKey(view: DaroRNAdBannerViewContainer, adUnitKey: String?) {
|
|
82
|
+
view.adUnitKey = adUnitKey.orEmpty()
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
@ReactProp(name = "adFormat")
|
|
@@ -92,6 +92,11 @@ class DaroRNAdBannerViewManager : SimpleViewManager<DaroRNAdBannerViewContainer>
|
|
|
92
92
|
view.loadOnMount = loadOnMount
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
@ReactProp(name = "preloadId")
|
|
96
|
+
override fun setPreloadId(view: DaroRNAdBannerViewContainer, preloadId: String?) {
|
|
97
|
+
view.preloadId = preloadId
|
|
98
|
+
}
|
|
99
|
+
|
|
95
100
|
override fun loadAd(view: DaroRNAdBannerViewContainer) {
|
|
96
101
|
view.loadAd()
|
|
97
102
|
}
|
|
@@ -87,9 +87,9 @@ class DaroRNAdNativeViewManager : ViewGroupManager<DaroRNAdNativeViewContainer>(
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
@ReactProp(name = "
|
|
91
|
-
override fun
|
|
92
|
-
view.
|
|
90
|
+
@ReactProp(name = "adUnitKey")
|
|
91
|
+
override fun setAdUnitKey(view: DaroRNAdNativeViewContainer, adUnitKey: String?) {
|
|
92
|
+
view.adUnitKey = adUnitKey.orEmpty()
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
@ReactProp(name = "loadOnMount")
|
|
@@ -97,6 +97,11 @@ class DaroRNAdNativeViewManager : ViewGroupManager<DaroRNAdNativeViewContainer>(
|
|
|
97
97
|
view.loadOnMount = loadOnMount
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
@ReactProp(name = "preloadId")
|
|
101
|
+
override fun setPreloadId(view: DaroRNAdNativeViewContainer, preloadId: String?) {
|
|
102
|
+
view.preloadId = preloadId
|
|
103
|
+
}
|
|
104
|
+
|
|
100
105
|
@ReactProp(name = "adChoicesPosition")
|
|
101
106
|
override fun setAdChoicesPosition(view: DaroRNAdNativeViewContainer, value: String?) {
|
|
102
107
|
view.setAdChoicesPosition(value)
|
|
@@ -7,10 +7,12 @@ import com.daro.reactnative.event.AppOpenEvent
|
|
|
7
7
|
import com.daro.reactnative.event.DaroRNEvent
|
|
8
8
|
import com.daro.reactnative.event.InterstitialEvent
|
|
9
9
|
import com.daro.reactnative.event.LightPopupEvent
|
|
10
|
+
import com.daro.reactnative.event.PreloadEvent
|
|
10
11
|
import com.daro.reactnative.event.RewardedEvent
|
|
11
12
|
import com.daro.reactnative.impl.DaroRNBannerViewModuleImpl
|
|
12
13
|
import com.daro.reactnative.impl.DaroRNInterstitialModuleImpl
|
|
13
14
|
import com.daro.reactnative.impl.DaroRNLightPopupModuleImpl
|
|
15
|
+
import com.daro.reactnative.impl.DaroRNPreloadModuleImpl
|
|
14
16
|
import com.daro.reactnative.impl.DaroRNRewardedAdModuleImpl
|
|
15
17
|
import com.daro.reactnative.util.DaroQaProbe
|
|
16
18
|
import com.daro.reactnative.util.EventEmitterUtil
|
|
@@ -200,6 +202,7 @@ class DaroRNModule(reactContext: ReactApplicationContext) :
|
|
|
200
202
|
constants.putAll(daroRNLightPopupModule.getComponents())
|
|
201
203
|
constants.putAll(daroRNAppOpenModule.getComponents())
|
|
202
204
|
constants.putAll(daroRNBannerModule.getComponents())
|
|
205
|
+
constants.putAll(daroRNPreloadModule.getComponents())
|
|
203
206
|
|
|
204
207
|
return constants
|
|
205
208
|
}
|
|
@@ -219,9 +222,9 @@ class DaroRNModule(reactContext: ReactApplicationContext) :
|
|
|
219
222
|
@OptIn(ExperimentalStdlibApi::class)
|
|
220
223
|
internal abstract class DaroRNInterstitialModule(context: ReactContext) :
|
|
221
224
|
DaroRNComponentModule(context) {
|
|
222
|
-
abstract fun isInterstitialReady(requestId: Int,
|
|
223
|
-
abstract fun loadInterstitial(requestId: Int,
|
|
224
|
-
abstract fun showInterstitial(requestId: Int,
|
|
225
|
+
abstract fun isInterstitialReady(requestId: Int, adUnitKey: String, promise: Promise)
|
|
226
|
+
abstract fun loadInterstitial(requestId: Int, adUnitKey: String)
|
|
227
|
+
abstract fun showInterstitial(requestId: Int, adUnitKey: String)
|
|
225
228
|
|
|
226
229
|
override fun getComponents(): MutableMap<String, Any> {
|
|
227
230
|
return InterstitialEvent.entries.associate { it.value to it.value }.toMutableMap()
|
|
@@ -235,28 +238,28 @@ class DaroRNModule(reactContext: ReactApplicationContext) :
|
|
|
235
238
|
)
|
|
236
239
|
|
|
237
240
|
@ReactMethod
|
|
238
|
-
override fun isInterstitialReady(requestId: Double,
|
|
239
|
-
daroRNInterstitialModule.isInterstitialReady(requestId.toInt(),
|
|
241
|
+
override fun isInterstitialReady(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
242
|
+
daroRNInterstitialModule.isInterstitialReady(requestId.toInt(), adUnitKey, promise)
|
|
240
243
|
}
|
|
241
244
|
|
|
242
245
|
@ReactMethod
|
|
243
|
-
override fun loadInterstitial(requestId: Double,
|
|
244
|
-
daroRNInterstitialModule.loadInterstitial(requestId.toInt(),
|
|
246
|
+
override fun loadInterstitial(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
247
|
+
daroRNInterstitialModule.loadInterstitial(requestId.toInt(), adUnitKey)
|
|
245
248
|
promise.resolve(null)
|
|
246
249
|
}
|
|
247
250
|
|
|
248
251
|
@ReactMethod
|
|
249
|
-
override fun showInterstitial(requestId: Double,
|
|
250
|
-
daroRNInterstitialModule.showInterstitial(requestId.toInt(),
|
|
252
|
+
override fun showInterstitial(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
253
|
+
daroRNInterstitialModule.showInterstitial(requestId.toInt(), adUnitKey)
|
|
251
254
|
promise.resolve(null)
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
@OptIn(ExperimentalStdlibApi::class)
|
|
255
258
|
internal abstract class DaroRNRewardedModule(context: ReactContext) :
|
|
256
259
|
DaroRNComponentModule(context) {
|
|
257
|
-
abstract fun isRewardedAdReady(requestId: Int,
|
|
258
|
-
abstract fun loadRewardedAd(requestId: Int,
|
|
259
|
-
abstract fun showRewardedAd(requestId: Int,
|
|
260
|
+
abstract fun isRewardedAdReady(requestId: Int, adUnitKey: String, promise: Promise)
|
|
261
|
+
abstract fun loadRewardedAd(requestId: Int, adUnitKey: String)
|
|
262
|
+
abstract fun showRewardedAd(requestId: Int, adUnitKey: String, customData: String?)
|
|
260
263
|
|
|
261
264
|
override fun getComponents(): MutableMap<String, Any> {
|
|
262
265
|
return RewardedEvent.entries.associate { it.value to it.value }.toMutableMap()
|
|
@@ -270,37 +273,37 @@ class DaroRNModule(reactContext: ReactApplicationContext) :
|
|
|
270
273
|
)
|
|
271
274
|
|
|
272
275
|
@ReactMethod
|
|
273
|
-
override fun isRewardedAdReady(requestId: Double,
|
|
274
|
-
daroRNRewardedModule.isRewardedAdReady(requestId.toInt(),
|
|
276
|
+
override fun isRewardedAdReady(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
277
|
+
daroRNRewardedModule.isRewardedAdReady(requestId.toInt(), adUnitKey, promise)
|
|
275
278
|
}
|
|
276
279
|
|
|
277
280
|
@ReactMethod
|
|
278
|
-
override fun loadRewardedAd(requestId: Double,
|
|
279
|
-
daroRNRewardedModule.loadRewardedAd(requestId.toInt(),
|
|
281
|
+
override fun loadRewardedAd(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
282
|
+
daroRNRewardedModule.loadRewardedAd(requestId.toInt(), adUnitKey)
|
|
280
283
|
promise.resolve(null)
|
|
281
284
|
}
|
|
282
285
|
|
|
283
286
|
@ReactMethod
|
|
284
287
|
override fun showRewardedAd(
|
|
285
288
|
requestId: Double,
|
|
286
|
-
|
|
289
|
+
adUnitKey: String,
|
|
287
290
|
customData: String?,
|
|
288
291
|
promise: Promise,
|
|
289
292
|
) {
|
|
290
|
-
daroRNRewardedModule.showRewardedAd(requestId.toInt(),
|
|
293
|
+
daroRNRewardedModule.showRewardedAd(requestId.toInt(), adUnitKey, customData)
|
|
291
294
|
promise.resolve(null)
|
|
292
295
|
}
|
|
293
296
|
|
|
294
297
|
@OptIn(ExperimentalStdlibApi::class)
|
|
295
298
|
internal abstract class DaroRNLightPopupModule(context: ReactContext) :
|
|
296
299
|
DaroRNComponentModule(context) {
|
|
297
|
-
abstract fun isLightPopupReady(requestId: Int,
|
|
300
|
+
abstract fun isLightPopupReady(requestId: Int, adUnitKey: String, promise: Promise)
|
|
298
301
|
abstract fun destroyLightPopup(requestId: Int)
|
|
299
302
|
abstract fun invalidate()
|
|
300
|
-
abstract fun loadLightPopup(requestId: Int,
|
|
301
|
-
abstract fun showLightPopup(requestId: Int,
|
|
303
|
+
abstract fun loadLightPopup(requestId: Int, adUnitKey: String)
|
|
304
|
+
abstract fun showLightPopup(requestId: Int, adUnitKey: String)
|
|
302
305
|
|
|
303
|
-
abstract fun setLightPopupAdConfiguration(requestId: Int,
|
|
306
|
+
abstract fun setLightPopupAdConfiguration(requestId: Int, adUnitKey: String, parameterMap: ReadableMap)
|
|
304
307
|
|
|
305
308
|
override fun getComponents(): MutableMap<String, Any> {
|
|
306
309
|
return LightPopupEvent.entries.associate { it.value to it.value }.toMutableMap()
|
|
@@ -314,39 +317,40 @@ class DaroRNModule(reactContext: ReactApplicationContext) :
|
|
|
314
317
|
|
|
315
318
|
override fun invalidate() {
|
|
316
319
|
daroRNLightPopupModule.invalidate()
|
|
320
|
+
daroRNPreloadModule.invalidate()
|
|
317
321
|
super.invalidate()
|
|
318
322
|
}
|
|
319
323
|
|
|
320
324
|
@ReactMethod
|
|
321
|
-
override fun destroyLightPopup(requestId: Double,
|
|
325
|
+
override fun destroyLightPopup(requestId: Double, adUnitKey: String) {
|
|
322
326
|
daroRNLightPopupModule.destroyLightPopup(requestId.toInt())
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
@ReactMethod
|
|
326
|
-
override fun isLightPopupReady(requestId: Double,
|
|
327
|
-
daroRNLightPopupModule.isLightPopupReady(requestId.toInt(),
|
|
330
|
+
override fun isLightPopupReady(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
331
|
+
daroRNLightPopupModule.isLightPopupReady(requestId.toInt(), adUnitKey, promise)
|
|
328
332
|
}
|
|
329
333
|
|
|
330
334
|
@ReactMethod
|
|
331
|
-
override fun loadLightPopup(requestId: Double,
|
|
332
|
-
daroRNLightPopupModule.loadLightPopup(requestId.toInt(),
|
|
335
|
+
override fun loadLightPopup(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
336
|
+
daroRNLightPopupModule.loadLightPopup(requestId.toInt(), adUnitKey)
|
|
333
337
|
promise.resolve(null)
|
|
334
338
|
}
|
|
335
339
|
|
|
336
340
|
@ReactMethod
|
|
337
|
-
override fun showLightPopup(requestId: Double,
|
|
338
|
-
daroRNLightPopupModule.showLightPopup(requestId.toInt(),
|
|
341
|
+
override fun showLightPopup(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
342
|
+
daroRNLightPopupModule.showLightPopup(requestId.toInt(), adUnitKey)
|
|
339
343
|
promise.resolve(null)
|
|
340
344
|
}
|
|
341
345
|
|
|
342
346
|
@ReactMethod
|
|
343
347
|
override fun setLightPopupAdConfiguration(
|
|
344
348
|
requestId: Double,
|
|
345
|
-
|
|
349
|
+
adUnitKey: String,
|
|
346
350
|
configuration: ReadableMap,
|
|
347
351
|
promise: Promise,
|
|
348
352
|
) {
|
|
349
|
-
daroRNLightPopupModule.setLightPopupAdConfiguration(requestId.toInt(),
|
|
353
|
+
daroRNLightPopupModule.setLightPopupAdConfiguration(requestId.toInt(), adUnitKey, configuration)
|
|
350
354
|
promise.resolve(null)
|
|
351
355
|
}
|
|
352
356
|
|
|
@@ -360,19 +364,19 @@ class DaroRNModule(reactContext: ReactApplicationContext) :
|
|
|
360
364
|
private val daroRNAppOpenModule: DaroRNAppOpenModule = object : DaroRNAppOpenModule(reactContext) {}
|
|
361
365
|
|
|
362
366
|
@ReactMethod
|
|
363
|
-
override fun isAppOpenAdReady(requestId: Double,
|
|
367
|
+
override fun isAppOpenAdReady(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
364
368
|
promise.reject(APP_OPEN_UNSUPPORTED_CODE, APP_OPEN_UNSUPPORTED_MESSAGE)
|
|
365
369
|
}
|
|
366
370
|
|
|
367
371
|
@ReactMethod
|
|
368
|
-
override fun loadAppOpenAd(requestId: Double,
|
|
372
|
+
override fun loadAppOpenAd(requestId: Double, adUnitKey: String, promise: Promise) {
|
|
369
373
|
promise.reject(APP_OPEN_UNSUPPORTED_CODE, APP_OPEN_UNSUPPORTED_MESSAGE)
|
|
370
374
|
}
|
|
371
375
|
|
|
372
376
|
@ReactMethod
|
|
373
377
|
override fun showAppOpenAd(
|
|
374
378
|
requestId: Double,
|
|
375
|
-
|
|
379
|
+
adUnitKey: String,
|
|
376
380
|
customData: String?,
|
|
377
381
|
promise: Promise,
|
|
378
382
|
) {
|
|
@@ -388,4 +392,42 @@ class DaroRNModule(reactContext: ReactApplicationContext) :
|
|
|
388
392
|
|
|
389
393
|
private val daroRNBannerModule: DaroRNBannerModule =
|
|
390
394
|
DaroRNBannerViewModuleImpl(context = reactContext)
|
|
395
|
+
|
|
396
|
+
@OptIn(ExperimentalStdlibApi::class)
|
|
397
|
+
internal abstract class DaroRNPreloadModule(context: ReactContext) : DaroRNComponentModule(context) {
|
|
398
|
+
abstract fun preloadBannerAd(preloadId: String, adUnitKey: String, adFormat: String, promise: Promise)
|
|
399
|
+
abstract fun preloadNativeAd(preloadId: String, adUnitKey: String, promise: Promise)
|
|
400
|
+
abstract fun destroyAdPreload(preloadId: String)
|
|
401
|
+
abstract fun invalidate()
|
|
402
|
+
|
|
403
|
+
override fun getComponents(): MutableMap<String, Any> {
|
|
404
|
+
return PreloadEvent.entries.associate { it.value to it.value }.toMutableMap()
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
private val daroRNPreloadModule: DaroRNPreloadModule = DaroRNPreloadModuleImpl(
|
|
409
|
+
context = reactContext,
|
|
410
|
+
getCurrentActivity = { reactApplicationContext.currentActivity }
|
|
411
|
+
)
|
|
412
|
+
|
|
413
|
+
@ReactMethod
|
|
414
|
+
override fun preloadBannerAd(preloadId: String, adUnitKey: String, adFormat: String, promise: Promise) {
|
|
415
|
+
daroRNPreloadModule.preloadBannerAd(preloadId, adUnitKey, adFormat, promise)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// AdChoices 위치는 Android 에서 뷰의 바인더가 정한다. 광고를 받는 데는 쓰지 않는다.
|
|
419
|
+
@ReactMethod
|
|
420
|
+
override fun preloadNativeAd(
|
|
421
|
+
preloadId: String,
|
|
422
|
+
adUnitKey: String,
|
|
423
|
+
adChoicesPosition: String,
|
|
424
|
+
promise: Promise,
|
|
425
|
+
) {
|
|
426
|
+
daroRNPreloadModule.preloadNativeAd(preloadId, adUnitKey, promise)
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
@ReactMethod
|
|
430
|
+
override fun destroyAdPreload(preloadId: String) {
|
|
431
|
+
daroRNPreloadModule.destroyAdPreload(preloadId)
|
|
432
|
+
}
|
|
391
433
|
}
|
|
@@ -57,6 +57,14 @@ internal enum class AppOpenEvent : DaroRNEvent {
|
|
|
57
57
|
get() = name
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
internal enum class PreloadEvent : DaroRNEvent {
|
|
61
|
+
ON_AD_PRELOAD_SUCCESS_EVENT,
|
|
62
|
+
ON_AD_PRELOAD_FAILED_EVENT;
|
|
63
|
+
|
|
64
|
+
override val value: String
|
|
65
|
+
get() = name
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
internal enum class AdViewEvent(
|
|
61
69
|
val registrationName: String,
|
|
62
70
|
override val value: String,
|
|
@@ -27,36 +27,36 @@ internal class DaroRNInterstitialModuleImpl(
|
|
|
27
27
|
private val interstitialAdMap: MutableMap<Int, DaroInterstitialAd> = mutableMapOf()
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
override fun isInterstitialReady(requestId: Int,
|
|
30
|
+
override fun isInterstitialReady(requestId: Int, adUnitKey: String, promise: Promise) {
|
|
31
31
|
promise.resolve(retrieveAd(requestId) != null)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
override fun loadInterstitial(requestId: Int,
|
|
35
|
-
retrieveLoader(requestId,
|
|
34
|
+
override fun loadInterstitial(requestId: Int, adUnitKey: String) {
|
|
35
|
+
retrieveLoader(requestId, adUnitKey).load()
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
override fun showInterstitial(requestId: Int,
|
|
38
|
+
override fun showInterstitial(requestId: Int, adUnitKey: String) {
|
|
39
39
|
currentActivity?.let {
|
|
40
40
|
retrieveAd(requestId)?.apply {
|
|
41
41
|
setListener(object : DaroInterstitialAdListener {
|
|
42
42
|
override fun onDismiss(ad: DaroAdInfo) {
|
|
43
43
|
sendNativeEvent(
|
|
44
44
|
event = InterstitialEvent.ON_INTERSTITIAL_HIDDEN_EVENT,
|
|
45
|
-
params = AdInfoUtil.getAdInfo(requestId,
|
|
45
|
+
params = AdInfoUtil.getAdInfo(requestId, adUnitKey, ad),
|
|
46
46
|
)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
override fun onFailedToShow(ad: DaroAdInfo, error: DaroAdDisplayFailError) {
|
|
50
50
|
sendNativeEvent(
|
|
51
51
|
event = InterstitialEvent.ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT,
|
|
52
|
-
params = AdInfoUtil.getAdDisplayFailedInfo(requestId,
|
|
52
|
+
params = AdInfoUtil.getAdDisplayFailedInfo(requestId, adUnitKey, ad, error),
|
|
53
53
|
)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
override fun onShown(ad: DaroAdInfo) {
|
|
57
57
|
sendNativeEvent(
|
|
58
58
|
event = InterstitialEvent.ON_INTERSTITIAL_DISPLAYED_EVENT,
|
|
59
|
-
params = AdInfoUtil.getAdInfo(requestId,
|
|
59
|
+
params = AdInfoUtil.getAdInfo(requestId, adUnitKey, ad),
|
|
60
60
|
)
|
|
61
61
|
|
|
62
62
|
interstitialAdMap.remove(requestId)
|
|
@@ -65,14 +65,14 @@ internal class DaroRNInterstitialModuleImpl(
|
|
|
65
65
|
override fun onAdClicked(responseInfo: DaroAdInfo) {
|
|
66
66
|
sendNativeEvent(
|
|
67
67
|
event = InterstitialEvent.ON_INTERSTITIAL_CLICKED_EVENT,
|
|
68
|
-
params = AdInfoUtil.getAdInfo(requestId,
|
|
68
|
+
params = AdInfoUtil.getAdInfo(requestId, adUnitKey, responseInfo),
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
override fun onAdImpression(responseInfo: DaroAdInfo) {
|
|
73
73
|
sendNativeEvent(
|
|
74
74
|
event = InterstitialEvent.ON_INTERSTITIAL_AD_IMPRESSION_RECORDED,
|
|
75
|
-
params = AdInfoUtil.getAdInfo(requestId,
|
|
75
|
+
params = AdInfoUtil.getAdInfo(requestId, adUnitKey, responseInfo),
|
|
76
76
|
)
|
|
77
77
|
}
|
|
78
78
|
})
|
|
@@ -82,10 +82,10 @@ internal class DaroRNInterstitialModuleImpl(
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
private fun retrieveLoader(requestId: Int,
|
|
85
|
+
private fun retrieveLoader(requestId: Int, adUnitKey: String): DaroInterstitialAdLoader {
|
|
86
86
|
return loaderMap[requestId] ?: DaroInterstitialAdLoader(
|
|
87
87
|
context,
|
|
88
|
-
DaroInterstitialAdUnit(
|
|
88
|
+
DaroInterstitialAdUnit(adUnitKey)
|
|
89
89
|
).also {
|
|
90
90
|
loaderMap[requestId] = it
|
|
91
91
|
it.setListener(object : DaroInterstitialAdLoaderListener {
|
|
@@ -93,14 +93,14 @@ internal class DaroRNInterstitialModuleImpl(
|
|
|
93
93
|
interstitialAdMap[requestId] = ad
|
|
94
94
|
sendNativeEvent(
|
|
95
95
|
event = InterstitialEvent.ON_INTERSTITIAL_LOADED_EVENT,
|
|
96
|
-
params = AdInfoUtil.getAdInfo(requestId,
|
|
96
|
+
params = AdInfoUtil.getAdInfo(requestId, adUnitKey, responseInfo),
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
override fun onAdLoadFail(err: DaroAdLoadError) {
|
|
101
101
|
sendNativeEvent(
|
|
102
102
|
event = InterstitialEvent.ON_INTERSTITIAL_LOAD_FAILED_EVENT,
|
|
103
|
-
params = AdInfoUtil.getAdLoadFailedInfo(requestId,
|
|
103
|
+
params = AdInfoUtil.getAdLoadFailedInfo(requestId, adUnitKey, err),
|
|
104
104
|
)
|
|
105
105
|
}
|
|
106
106
|
})
|
|
@@ -33,16 +33,16 @@ internal class DaroRNLightPopupModuleImpl(
|
|
|
33
33
|
init { context.addLifecycleEventListener(this) }
|
|
34
34
|
private val optionMap: MutableMap<Int, DaroLightPopupAdOptions> = mutableMapOf()
|
|
35
35
|
|
|
36
|
-
override fun isLightPopupReady(requestId: Int,
|
|
36
|
+
override fun isLightPopupReady(requestId: Int, adUnitKey: String, promise: Promise) {
|
|
37
37
|
context.runOnUiQueueThread { promise.resolve(requests[requestId]?.isReady == true) }
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
override fun loadLightPopup(requestId: Int,
|
|
40
|
+
override fun loadLightPopup(requestId: Int, adUnitKey: String) {
|
|
41
41
|
context.runOnUiQueueThread {
|
|
42
42
|
if (invalidated) return@runOnUiQueueThread
|
|
43
43
|
requests.remove(requestId)?.destroy()
|
|
44
44
|
val loader = DaroLightPopupAdLoader(
|
|
45
|
-
context, DaroLightPopupAdUnit(
|
|
45
|
+
context, DaroLightPopupAdUnit(adUnitKey, optionMap[requestId] ?: DaroLightPopupAdOptions())
|
|
46
46
|
)
|
|
47
47
|
val request = LightPopupRequest(loader::destroy, DaroLightPopupAd::destroy)
|
|
48
48
|
requests[requestId] = request
|
|
@@ -50,12 +50,12 @@ internal class DaroRNLightPopupModuleImpl(
|
|
|
50
50
|
override fun onAdLoadSuccess(ad: DaroLightPopupAd, responseInfo: DaroAdInfo) {
|
|
51
51
|
if (!request.accept(ad)) return
|
|
52
52
|
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_LOADED_EVENT,
|
|
53
|
-
AdInfoUtil.getAdInfo(requestId,
|
|
53
|
+
AdInfoUtil.getAdInfo(requestId, adUnitKey, responseInfo))
|
|
54
54
|
}
|
|
55
55
|
override fun onAdLoadFail(err: DaroAdLoadError) {
|
|
56
56
|
if (!request.active) return
|
|
57
57
|
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_LOAD_FAILED_EVENT,
|
|
58
|
-
AdInfoUtil.getAdLoadFailedInfo(requestId,
|
|
58
|
+
AdInfoUtil.getAdLoadFailedInfo(requestId, adUnitKey, err))
|
|
59
59
|
}
|
|
60
60
|
})
|
|
61
61
|
loader.load()
|
|
@@ -64,7 +64,7 @@ internal class DaroRNLightPopupModuleImpl(
|
|
|
64
64
|
|
|
65
65
|
override fun setLightPopupAdConfiguration(
|
|
66
66
|
requestId: Int,
|
|
67
|
-
|
|
67
|
+
adUnitKey: String,
|
|
68
68
|
parameterMap: ReadableMap,
|
|
69
69
|
) {
|
|
70
70
|
val newOption = DaroLightPopupAdOptions().let {
|
|
@@ -94,7 +94,7 @@ internal class DaroRNLightPopupModuleImpl(
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
override fun showLightPopup(requestId: Int,
|
|
97
|
+
override fun showLightPopup(requestId: Int, adUnitKey: String) {
|
|
98
98
|
context.runOnUiQueueThread {
|
|
99
99
|
val activity = currentActivity ?: return@runOnUiQueueThread
|
|
100
100
|
val request = requests[requestId] ?: return@runOnUiQueueThread
|
|
@@ -104,28 +104,28 @@ internal class DaroRNLightPopupModuleImpl(
|
|
|
104
104
|
if (!request.ownsPresentation(popup)) return
|
|
105
105
|
request.finishPresentation(popup)
|
|
106
106
|
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_HIDDEN_EVENT,
|
|
107
|
-
AdInfoUtil.getAdInfo(requestId,
|
|
107
|
+
AdInfoUtil.getAdInfo(requestId, adUnitKey, ad))
|
|
108
108
|
}
|
|
109
109
|
override fun onFailedToShow(ad: DaroAdInfo, error: DaroAdDisplayFailError) {
|
|
110
110
|
if (!request.ownsPresentation(popup)) return
|
|
111
111
|
request.finishPresentation(popup)
|
|
112
112
|
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT,
|
|
113
|
-
AdInfoUtil.getAdDisplayFailedInfo(requestId,
|
|
113
|
+
AdInfoUtil.getAdDisplayFailedInfo(requestId, adUnitKey, ad, error))
|
|
114
114
|
}
|
|
115
115
|
override fun onShown(ad: DaroAdInfo) {
|
|
116
116
|
if (!request.ownsPresentation(popup)) return
|
|
117
117
|
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_DISPLAYED_EVENT,
|
|
118
|
-
AdInfoUtil.getAdInfo(requestId,
|
|
118
|
+
AdInfoUtil.getAdInfo(requestId, adUnitKey, ad))
|
|
119
119
|
}
|
|
120
120
|
override fun onAdClicked(responseInfo: DaroAdInfo) {
|
|
121
121
|
if (!request.ownsPresentation(popup)) return
|
|
122
122
|
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_CLICKED_EVENT,
|
|
123
|
-
AdInfoUtil.getAdInfo(requestId,
|
|
123
|
+
AdInfoUtil.getAdInfo(requestId, adUnitKey, responseInfo))
|
|
124
124
|
}
|
|
125
125
|
override fun onAdImpression(responseInfo: DaroAdInfo) {
|
|
126
126
|
if (!request.ownsPresentation(popup)) return
|
|
127
127
|
sendNativeEvent(LightPopupEvent.ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED,
|
|
128
|
-
AdInfoUtil.getAdInfo(requestId,
|
|
128
|
+
AdInfoUtil.getAdInfo(requestId, adUnitKey, responseInfo))
|
|
129
129
|
}
|
|
130
130
|
})
|
|
131
131
|
popup.show(activity)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
package com.daro.reactnative.impl
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import com.daro.reactnative.DaroRNModule
|
|
5
|
+
import com.daro.reactnative.constants.InternalDaroRNBannerSize
|
|
6
|
+
import com.daro.reactnative.event.PreloadEvent
|
|
7
|
+
import com.daro.reactnative.preload.DaroRNPreloadRegistry
|
|
8
|
+
import com.daro.reactnative.util.AdInfoUtil
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.UiThreadUtil
|
|
12
|
+
import droom.daro.core.adunit.DaroBannerAdUnit
|
|
13
|
+
import droom.daro.core.adunit.DaroNativeAdUnit
|
|
14
|
+
import droom.daro.core.listener.DaroPreloadListener
|
|
15
|
+
import droom.daro.core.model.DaroAdInfo
|
|
16
|
+
import droom.daro.core.model.DaroError
|
|
17
|
+
import droom.daro.view.DaroBannerAdController
|
|
18
|
+
import droom.daro.view.DaroNativeAdController
|
|
19
|
+
|
|
20
|
+
internal class DaroRNPreloadModuleImpl(
|
|
21
|
+
context: ReactApplicationContext,
|
|
22
|
+
private val getCurrentActivity: () -> Activity?,
|
|
23
|
+
private val registry: DaroRNPreloadRegistry = DaroRNPreloadRegistry.shared,
|
|
24
|
+
) : DaroRNModule.DaroRNPreloadModule(context) {
|
|
25
|
+
|
|
26
|
+
override fun preloadBannerAd(preloadId: String, adUnitKey: String, adFormat: String, promise: Promise) {
|
|
27
|
+
val size = InternalDaroRNBannerSize.fromName(adFormat).toBannerSize()
|
|
28
|
+
?: return promise.reject("INVALID_AD_FORMAT", "Unknown banner ad format: $adFormat")
|
|
29
|
+
preload(preloadId, promise) { activity ->
|
|
30
|
+
val controller = DaroBannerAdController(activity, DaroBannerAdUnit(adUnitKey, bannerSize = size))
|
|
31
|
+
controller.setListener(listener(preloadId, adUnitKey))
|
|
32
|
+
DaroRNPreloadRegistry.Entry(adUnitKey, size.name, controller, { it.preload() }, { it.destroy() })
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override fun preloadNativeAd(preloadId: String, adUnitKey: String, promise: Promise) {
|
|
37
|
+
preload(preloadId, promise) { activity ->
|
|
38
|
+
val controller = DaroNativeAdController(activity, DaroNativeAdUnit(adUnitKey))
|
|
39
|
+
controller.setListener(listener(preloadId, adUnitKey))
|
|
40
|
+
DaroRNPreloadRegistry.Entry(adUnitKey, "", controller, { it.preload() }, { it.destroy() })
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override fun destroyAdPreload(preloadId: String) {
|
|
45
|
+
UiThreadUtil.runOnUiThread { registry.destroy(preloadId) }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override fun invalidate() {
|
|
49
|
+
UiThreadUtil.runOnUiThread { registry.destroyAll() }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 컨트롤러는 Activity 를 받는다. 뷰도 같은 Activity 로 만들어야 받아 둔 광고를 넘겨받는다.
|
|
53
|
+
private fun preload(preloadId: String, promise: Promise, create: (Activity) -> DaroRNPreloadRegistry.Entry<*>) {
|
|
54
|
+
UiThreadUtil.runOnUiThread {
|
|
55
|
+
val activity = getCurrentActivity()
|
|
56
|
+
?: return@runOnUiThread promise.reject("NO_ACTIVITY", "Preload requires a foreground Activity")
|
|
57
|
+
registry.preload(preloadId) { create(activity) }
|
|
58
|
+
promise.resolve(null)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private fun listener(preloadId: String, adUnitKey: String) = object : DaroPreloadListener {
|
|
63
|
+
override fun onPreloadSuccess(adInfo: DaroAdInfo) {
|
|
64
|
+
sendNativeEvent(
|
|
65
|
+
event = PreloadEvent.ON_AD_PRELOAD_SUCCESS_EVENT,
|
|
66
|
+
params = AdInfoUtil.getAdInfo(adUnitKey, adInfo).apply { putString("preloadId", preloadId) },
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
override fun onPreloadFail(error: DaroError) {
|
|
71
|
+
sendNativeEvent(
|
|
72
|
+
event = PreloadEvent.ON_AD_PRELOAD_FAILED_EVENT,
|
|
73
|
+
params = AdInfoUtil.getPreloadFailedInfo(adUnitKey, error).apply { putString("preloadId", preloadId) },
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|