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.
Files changed (179) hide show
  1. package/README.md +2 -5
  2. package/android/build.gradle +7 -13
  3. package/android/src/main/java/com/daro/reactnative/DaroRNAdBannerViewManager.kt +105 -0
  4. package/android/src/main/java/com/daro/reactnative/{DaroMAdNativeViewManager.kt → DaroRNAdNativeViewManager.kt} +34 -38
  5. package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +388 -0
  6. package/android/src/main/java/com/daro/reactnative/{DaroMPackage.kt → DaroRNPackage.kt} +7 -7
  7. package/android/src/main/java/com/daro/reactnative/DaroSdkBridge.kt +52 -0
  8. package/android/src/main/java/com/daro/reactnative/constants/{InternalDaroMBannerSize.kt → InternalDaroRNBannerSize.kt} +2 -2
  9. package/android/src/main/java/com/daro/reactnative/event/{DaroMEvent.kt → DaroRNEvent.kt} +8 -7
  10. package/android/src/main/java/com/daro/reactnative/impl/{DaroMBannerViewModuleImpl.kt → DaroRNBannerViewModuleImpl.kt} +3 -3
  11. package/android/src/main/java/com/daro/reactnative/impl/{DaroMInterstitialModuleImpl.kt → DaroRNInterstitialModuleImpl.kt} +4 -4
  12. package/android/src/main/java/com/daro/reactnative/impl/DaroRNLightPopupModuleImpl.kt +163 -0
  13. package/android/src/main/java/com/daro/reactnative/impl/{DaroMRewardedAdModuleImpl.kt → DaroRNRewardedAdModuleImpl.kt} +4 -4
  14. package/android/src/main/java/com/daro/reactnative/impl/LightPopupRequest.kt +51 -0
  15. package/android/src/main/java/com/daro/reactnative/util/AdInfoUtil.kt +12 -0
  16. package/android/src/main/java/com/daro/reactnative/util/DaroQaProbe.kt +147 -0
  17. package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +2 -2
  18. package/android/src/main/java/com/daro/reactnative/view/{DaroMAdBannerViewContainer.kt → DaroRNAdBannerViewContainer.kt} +2 -3
  19. package/android/src/main/java/com/daro/reactnative/view/{DaroMAdNativeViewContainer.kt → DaroRNAdNativeViewContainer.kt} +23 -4
  20. package/android/src/newarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt} +1 -1
  21. package/android/src/oldarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt} +35 -3
  22. package/android/src/test/java/com/daro/reactnative/impl/LightPopupRequestTest.kt +62 -0
  23. package/ios/{DaroMModule+AppOpen.swift → DaroRNModule+AppOpen.swift} +10 -11
  24. package/ios/DaroRNModule+Consent.swift +88 -0
  25. package/ios/{DaroMModule+Interstitial.swift → DaroRNModule+Interstitial.swift} +9 -9
  26. package/ios/DaroRNModule+LightPopup.swift +211 -0
  27. package/ios/DaroRNModule+Qa.swift +159 -0
  28. package/ios/{DaroMModule+Rewarded.swift → DaroRNModule+Rewarded.swift} +10 -10
  29. package/ios/{DaroMModule.mm → DaroRNModule.mm} +20 -4
  30. package/ios/{DaroMModule.swift → DaroRNModule.swift} +32 -6
  31. package/ios/Fabric/DaroRNAdBannerComponentView.mm +219 -0
  32. package/ios/Fabric/{DaroMFabricEventSink.mm → DaroRNFabricEventSink.mm} +4 -4
  33. package/ios/Fabric/{DaroMFabricPropApplier.mm → DaroRNFabricPropApplier.mm} +14 -14
  34. package/ios/Fabric/DaroRNNativeAdComponentView.mm +320 -0
  35. package/ios/Paper/{DaroMAdBannerViewManager.m → DaroRNAdBannerViewManager.m} +1 -1
  36. package/ios/Paper/{DaroMAdBannerViewManager.swift → DaroRNAdBannerViewManager.swift} +5 -5
  37. package/ios/Paper/{DaroMNativeAdViewManager.m → DaroRNNativeAdViewManager.m} +2 -1
  38. package/ios/Paper/DaroRNNativeAdViewManager.swift +22 -0
  39. package/ios/Shared/DaroMediationDebugger.swift +14 -0
  40. package/ios/Shared/{DaroMAdEventSink.swift → DaroRNAdEventSink.swift} +2 -1
  41. package/ios/Shared/{DaroMBannerAdView.swift → DaroRNBannerAdView.swift} +11 -11
  42. package/ios/Shared/{DaroMNativeAdLoadCoordinator.swift → DaroRNNativeAdLoadCoordinator.swift} +4 -4
  43. package/ios/Shared/{DaroMNativeAdView.swift → DaroRNNativeAdView.swift} +29 -21
  44. package/ios/Shared/{DaroMNativeAssetResolver.swift → DaroRNNativeAssetResolver.swift} +6 -6
  45. package/lib/commonjs/AdBannerView.js +3 -5
  46. package/lib/commonjs/AdBannerView.js.map +1 -1
  47. package/lib/commonjs/AppOpenAd.js +4 -4
  48. package/lib/commonjs/AppOpenAd.js.map +1 -1
  49. package/lib/commonjs/{DaroMAdBannerViewNativeComponent.ts → DaroRNAdBannerViewNativeComponent.ts} +5 -2
  50. package/{src/DaroMNativeAdViewNativeComponent.ts → lib/commonjs/DaroRNNativeAdViewNativeComponent.ts} +8 -2
  51. package/lib/commonjs/LightPopupAd.js +15 -1
  52. package/lib/commonjs/LightPopupAd.js.map +1 -1
  53. package/lib/commonjs/NativeDaroModule.js +1 -1
  54. package/lib/commonjs/NativeDaroModule.js.map +1 -1
  55. package/lib/commonjs/hooks/useLightPopupAd.js +6 -4
  56. package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -1
  57. package/lib/commonjs/index.js +121 -0
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/commonjs/nativeAd/NativeAdView.js +10 -3
  60. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
  61. package/lib/commonjs/types/NativeAdViewProps.js +21 -0
  62. package/lib/commonjs/types/NativeAdViewProps.js.map +1 -1
  63. package/lib/module/AdBannerView.js +1 -3
  64. package/lib/module/AdBannerView.js.map +1 -1
  65. package/lib/module/AppOpenAd.js +4 -4
  66. package/lib/module/AppOpenAd.js.map +1 -1
  67. package/{src/DaroMAdBannerViewNativeComponent.ts → lib/module/DaroRNAdBannerViewNativeComponent.ts} +5 -2
  68. package/lib/{commonjs/DaroMNativeAdViewNativeComponent.ts → module/DaroRNNativeAdViewNativeComponent.ts} +8 -2
  69. package/lib/module/LightPopupAd.js +15 -1
  70. package/lib/module/LightPopupAd.js.map +1 -1
  71. package/lib/module/NativeDaroModule.js +1 -1
  72. package/lib/module/NativeDaroModule.js.map +1 -1
  73. package/lib/module/hooks/useLightPopupAd.js +6 -4
  74. package/lib/module/hooks/useLightPopupAd.js.map +1 -1
  75. package/lib/module/index.js +101 -0
  76. package/lib/module/index.js.map +1 -1
  77. package/lib/module/nativeAd/NativeAdView.js +8 -1
  78. package/lib/module/nativeAd/NativeAdView.js.map +1 -1
  79. package/lib/module/types/NativeAdViewProps.js +22 -1
  80. package/lib/module/types/NativeAdViewProps.js.map +1 -1
  81. package/lib/typescript/commonjs/plugin/src/index.d.ts +2 -6
  82. package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +2 -6
  84. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/plugin/src/withIos.d.ts +2 -6
  86. package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/src/AppOpenAd.d.ts +2 -2
  89. package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/{DaroMAdBannerViewNativeComponent.d.ts → DaroRNAdBannerViewNativeComponent.d.ts} +3 -2
  91. package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/{DaroMNativeAdViewNativeComponent.d.ts → DaroRNNativeAdViewNativeComponent.d.ts} +6 -2
  93. package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/LightPopupAd.d.ts +3 -0
  95. package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +11 -1
  97. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/src/index.d.ts +79 -0
  100. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +2 -0
  102. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
  103. package/lib/typescript/commonjs/src/types/AdInfo.d.ts +15 -0
  104. package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/src/types/AdProps.d.ts +0 -1
  106. package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +9 -0
  108. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
  109. package/lib/typescript/module/plugin/src/index.d.ts +2 -6
  110. package/lib/typescript/module/plugin/src/index.d.ts.map +1 -1
  111. package/lib/typescript/module/plugin/src/withAndroid.d.ts +2 -6
  112. package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -1
  113. package/lib/typescript/module/plugin/src/withIos.d.ts +2 -6
  114. package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -1
  115. package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
  116. package/lib/typescript/module/src/AppOpenAd.d.ts +2 -2
  117. package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
  118. package/lib/typescript/module/src/{DaroMAdBannerViewNativeComponent.d.ts → DaroRNAdBannerViewNativeComponent.d.ts} +3 -2
  119. package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
  120. package/lib/typescript/module/src/{DaroMNativeAdViewNativeComponent.d.ts → DaroRNNativeAdViewNativeComponent.d.ts} +6 -2
  121. package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
  122. package/lib/typescript/module/src/LightPopupAd.d.ts +3 -0
  123. package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
  124. package/lib/typescript/module/src/NativeDaroModule.d.ts +11 -1
  125. package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -1
  126. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -1
  127. package/lib/typescript/module/src/index.d.ts +79 -0
  128. package/lib/typescript/module/src/index.d.ts.map +1 -1
  129. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +2 -0
  130. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
  131. package/lib/typescript/module/src/types/AdInfo.d.ts +15 -0
  132. package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
  133. package/lib/typescript/module/src/types/AdProps.d.ts +0 -1
  134. package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
  135. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +9 -0
  136. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
  137. package/package.json +8 -5
  138. package/plugin/build/index.d.ts +2 -6
  139. package/plugin/build/index.js +21 -56
  140. package/plugin/build/withAndroid.d.ts +2 -6
  141. package/plugin/build/withAndroid.js +48 -90
  142. package/plugin/build/withIos.d.ts +2 -6
  143. package/plugin/build/withIos.js +37 -33
  144. package/react-native-daro.podspec +2 -3
  145. package/src/AdBannerView.tsx +1 -3
  146. package/src/AppOpenAd.ts +2 -8
  147. package/{lib/module/DaroMAdBannerViewNativeComponent.ts → src/DaroRNAdBannerViewNativeComponent.ts} +5 -2
  148. package/{lib/module/DaroMNativeAdViewNativeComponent.ts → src/DaroRNNativeAdViewNativeComponent.ts} +8 -2
  149. package/src/LightPopupAd.ts +18 -1
  150. package/src/NativeDaroModule.ts +18 -2
  151. package/src/hooks/useLightPopupAd.ts +6 -4
  152. package/src/index.tsx +136 -0
  153. package/src/nativeAd/NativeAdView.tsx +22 -1
  154. package/src/types/AdInfo.ts +17 -0
  155. package/src/types/AdProps.ts +0 -2
  156. package/src/types/NativeAdViewProps.ts +10 -0
  157. package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +0 -23
  158. package/android/src/main/java/com/daro/reactnative/DaroMAdBannerViewManager.kt +0 -155
  159. package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +0 -257
  160. package/android/src/main/java/com/daro/reactnative/impl/DaroMLightPopupModuleImpl.kt +0 -150
  161. package/ios/DaroMModule+LightPopup.swift +0 -183
  162. package/ios/Fabric/DaroMAdBannerComponentView.mm +0 -207
  163. package/ios/Fabric/DaroMNativeAdComponentView.mm +0 -294
  164. package/ios/Paper/DaroMNativeAdViewManager.swift +0 -22
  165. package/ios/mediation/admob/DaroMediationDebugger.swift +0 -11
  166. package/lib/commonjs/types/DaroMMobileAds.js +0 -2
  167. package/lib/commonjs/types/DaroMMobileAds.js.map +0 -1
  168. package/lib/module/types/DaroMMobileAds.js +0 -2
  169. package/lib/module/types/DaroMMobileAds.js.map +0 -1
  170. package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +0 -1
  171. package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +0 -1
  172. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts +0 -6
  173. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +0 -1
  174. package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +0 -1
  175. package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +0 -1
  176. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts +0 -6
  177. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +0 -1
  178. package/src/types/DaroMMobileAds.ts +0 -5
  179. /package/ios/{mediation/admob → Shared}/DaroMediationTypes.swift +0 -0
@@ -1,150 +0,0 @@
1
- package com.daro.reactnative.impl
2
-
3
- import android.app.Activity
4
- import androidx.core.graphics.toColorInt
5
- import com.daro.reactnative.DaroMModule
6
- import com.daro.reactnative.event.LightPopupEvent
7
- import com.daro.reactnative.util.AdInfoUtil
8
- import com.facebook.react.bridge.Promise
9
- import com.facebook.react.bridge.ReactApplicationContext
10
- import com.facebook.react.bridge.ReadableMap
11
- import droom.daro.core.adunit.DaroLightPopupAdUnit
12
- import droom.daro.core.listener.DaroLightPopupAdListener
13
- import droom.daro.core.listener.DaroLightPopupAdLoaderListener
14
- import droom.daro.core.model.DaroAdDisplayFailError
15
- import droom.daro.core.model.DaroAdInfo
16
- import droom.daro.core.model.DaroAdLoadError
17
- import droom.daro.core.model.DaroLightPopupAd
18
- import droom.daro.core.model.DaroLightPopupAdOptions
19
- import droom.daro.loader.DaroLightPopupAdLoader
20
-
21
- internal class DaroMLightPopupModuleImpl(
22
- context: ReactApplicationContext,
23
- private val getCurrentActivity: () -> Activity?,
24
- ) : DaroMModule.DaroMLightPopupModule(context) {
25
-
26
- private val currentActivity: Activity?
27
- get() = getCurrentActivity()
28
-
29
- private val lightpopupAdMap: MutableMap<Int, DaroLightPopupAd> = mutableMapOf()
30
- private val optionMap: MutableMap<Int, DaroLightPopupAdOptions> = mutableMapOf()
31
- private val loaderMap: MutableMap<Int, DaroLightPopupAdLoader> = mutableMapOf()
32
-
33
- override fun isLightPopupReady(requestId: Int, adUnitId: String, promise: Promise) {
34
- promise.resolve(retrieveAd(requestId) != null)
35
- }
36
-
37
- override fun loadLightPopup(requestId: Int, adUnitId: String) {
38
- context.runOnUiQueueThread {
39
- retrieveLoader(requestId, adUnitId).load()
40
- }
41
- }
42
-
43
- override fun setLightPopupAdConfiguration(
44
- requestId: Int,
45
- adUnitId: String,
46
- parameterMap: ReadableMap,
47
- ) {
48
- val newOption = DaroLightPopupAdOptions().let {
49
- it.copy(
50
- backgroundColor = parameterMap.getString("backgroundColor")?.toColorInt()
51
- ?: it.backgroundColor,
52
- containerColor = parameterMap.getString("cardViewBackgroundColor")?.toColorInt()
53
- ?: it.containerColor,
54
- adMarkLabelTextColor = parameterMap.getString("adMarkLabelTextColor")?.toColorInt()
55
- ?: it.adMarkLabelTextColor,
56
- adMarkLabelBackgroundColor = parameterMap.getString("adMarkLabelBackgroundColor")
57
- ?.toColorInt() ?: it.adMarkLabelBackgroundColor,
58
- titleColor = parameterMap.getString("titleTextColor")?.toColorInt() ?: it.titleColor,
59
- bodyColor = parameterMap.getString("bodyTextColor")?.toColorInt() ?: it.bodyColor,
60
- ctaBackgroundColor = parameterMap.getString("ctaButtonBackgroundColor")?.toColorInt()
61
- ?: it.ctaBackgroundColor,
62
- ctaTextColor = parameterMap.getString("ctaButtonTextColor")?.toColorInt()
63
- ?: it.ctaTextColor,
64
- closeButtonText = parameterMap.getString("closeButtonText") ?: it.closeButtonText,
65
- closeButtonColor = parameterMap.getString("closeButtonTextColor")?.toColorInt()
66
- ?: it.closeButtonColor,
67
- )
68
- }
69
-
70
- optionMap[requestId] = newOption
71
- }
72
-
73
- override fun showLightPopup(requestId: Int, adUnitId: String) {
74
- currentActivity?.let {
75
- it.runOnUiThread {
76
- retrieveAd(requestId)?.apply {
77
- setListener(object : DaroLightPopupAdListener {
78
- override fun onDismiss(ad: DaroAdInfo) {
79
- sendNativeEvent(
80
- event = LightPopupEvent.ON_LIGHTPOPUP_HIDDEN_EVENT,
81
- params = AdInfoUtil.getAdInfo(requestId, adUnitId, ad),
82
- )
83
- }
84
-
85
- override fun onFailedToShow(ad: DaroAdInfo, error: DaroAdDisplayFailError) {
86
- sendNativeEvent(
87
- event = LightPopupEvent.ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT,
88
- params = AdInfoUtil.getAdDisplayFailedInfo(requestId, adUnitId, ad, error),
89
- )
90
- }
91
-
92
- override fun onShown(ad: DaroAdInfo) {
93
- sendNativeEvent(
94
- event = LightPopupEvent.ON_LIGHTPOPUP_DISPLAYED_EVENT,
95
- params = AdInfoUtil.getAdInfo(requestId, adUnitId, ad),
96
- )
97
-
98
- lightpopupAdMap.remove(requestId)
99
- }
100
-
101
- override fun onAdClicked(responseInfo: DaroAdInfo) {
102
- sendNativeEvent(
103
- event = LightPopupEvent.ON_LIGHTPOPUP_CLICKED_EVENT,
104
- params = AdInfoUtil.getAdInfo(requestId, adUnitId, responseInfo),
105
- )
106
- }
107
-
108
- override fun onAdImpression(responseInfo: DaroAdInfo) {
109
- sendNativeEvent(
110
- event = LightPopupEvent.ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED,
111
- params = AdInfoUtil.getAdInfo(requestId, adUnitId, responseInfo),
112
- )
113
- }
114
- })
115
-
116
- show(it)
117
- }
118
- }
119
- }
120
- }
121
-
122
- private fun retrieveLoader(requestId: Int, adUnitId: String): DaroLightPopupAdLoader {
123
- return loaderMap[requestId] ?: DaroLightPopupAdLoader(
124
- context,
125
- DaroLightPopupAdUnit(adUnitId, adUnitId, optionMap[requestId] ?: DaroLightPopupAdOptions())
126
- ).also {
127
- loaderMap[requestId] = it
128
- it.setListener(object : DaroLightPopupAdLoaderListener {
129
- override fun onAdLoadSuccess(ad: DaroLightPopupAd, responseInfo: DaroAdInfo) {
130
- lightpopupAdMap[requestId] = ad
131
- sendNativeEvent(
132
- event = LightPopupEvent.ON_LIGHTPOPUP_LOADED_EVENT,
133
- params = AdInfoUtil.getAdInfo(requestId, adUnitId, responseInfo),
134
- )
135
- }
136
-
137
- override fun onAdLoadFail(err: DaroAdLoadError) {
138
- sendNativeEvent(
139
- event = LightPopupEvent.ON_LIGHTPOPUP_LOAD_FAILED_EVENT,
140
- params = AdInfoUtil.getAdLoadFailedInfo(requestId, adUnitId, err),
141
- )
142
- }
143
- })
144
- }
145
- }
146
-
147
- private fun retrieveAd(requestId: Int): DaroLightPopupAd? {
148
- return lightpopupAdMap[requestId]
149
- }
150
- }
@@ -1,183 +0,0 @@
1
- import React
2
- import UIKit
3
- // MARK: - LightPopup Ad
4
- extension DaroMModule {
5
-
6
- @objc(isLightPopupReady:adUnitId:resolve:reject:)
7
- func isLightPopupReady(
8
- requestId: Double,
9
- adUnitId: String,
10
- resolve: RCTPromiseResolveBlock,
11
- reject: RCTPromiseRejectBlock
12
- ) {
13
- let requestId = Int(requestId)
14
- if !Self.sdkInitialized {
15
- DaroMModule.logger.debug("[DaroMMobileAds] !isInitialized")
16
- resolve(false)
17
- return
18
- }
19
- resolve(lightPopups[requestId]?.loadedAd != nil)
20
- }
21
-
22
- @objc(loadLightPopup:adUnitId:resolve:reject:)
23
- func loadLightPopup(
24
- requestId: Double,
25
- adUnitId: String,
26
- resolve: RCTPromiseResolveBlock,
27
- reject: RCTPromiseRejectBlock
28
- ) {
29
- let requestId = Int(requestId)
30
- let lightPopupLoader = retrieveLightPopupLoader(requestId: requestId, adUnitId: adUnitId)
31
- lightPopupLoader.loadAd()
32
- resolve(Void())
33
- }
34
-
35
- @objc(showLightPopup:adUnitId:resolve:reject:)
36
- func showLightPopup(
37
- requestId: Double,
38
- adUnitId: String,
39
- resolve: @escaping RCTPromiseResolveBlock,
40
- reject: @escaping RCTPromiseRejectBlock
41
- ) {
42
- let requestId = Int(requestId)
43
- guard let loadedAd = lightPopups[requestId]?.loadedAd else {
44
- reject("LIGHTPOPUP_NOT_LOADED", "LightPopup ad not loaded", nil)
45
- return
46
- }
47
- let reqIdInt = requestId
48
- executeOnMainThread { [weak self] in
49
- guard let viewController = UIApplication.shared.windows.first?.rootViewController else {
50
- reject("VIEW_CONTROLLER_NOT_FOUND", "Root view controller not found", nil)
51
- return
52
- }
53
- self?.applyStoredConfiguration(to: loadedAd, for: reqIdInt)
54
- loadedAd.show(viewController: viewController)
55
- resolve(Void())
56
- }
57
- }
58
-
59
- @objc(setLightPopupAdConfiguration:adUnitId:configuration:resolve:reject:)
60
- func setLightPopupAdConfiguration(
61
- requestId: Double,
62
- adUnitId: String,
63
- configuration: [String: Any],
64
- resolve: RCTPromiseResolveBlock,
65
- reject: RCTPromiseRejectBlock
66
- ) {
67
- let reqIdInt = Int(requestId)
68
- guard let loadedAd = lightPopups[reqIdInt]?.loadedAd else {
69
- lightPopupConfigurations[reqIdInt] = configuration
70
- resolve(Void())
71
- return
72
- }
73
- lightPopupConfigurations[reqIdInt] = configuration
74
- executeOnMainThread { [weak self] in
75
- self?.applyStoredConfiguration(to: loadedAd, for: reqIdInt)
76
- }
77
- resolve(Void())
78
- }
79
-
80
- func applyStoredConfiguration(to ad: DaroLightPopupAd, for requestId: Int) {
81
- if let configuration = lightPopupConfigurations[requestId] {
82
- let lightPopupConfig = DaroLightPopupConfiguration()
83
-
84
- func setColorIfValid(_ key: String, setter: (UIColor) -> Void) {
85
- if let colorString = configuration[key] as? String {
86
- setter(UIColor(hex: colorString))
87
- }
88
- }
89
-
90
- setColorIfValid("backgroundColor") { lightPopupConfig.backgroundColor = $0 }
91
- setColorIfValid("cardViewBackgroundColor") { lightPopupConfig.cardViewBackgroundColor = $0 }
92
- setColorIfValid("adMarkLabelTextColor") { lightPopupConfig.adMarkLabelTextColor = $0 }
93
- setColorIfValid("adMarkLabelBackgroundColor") { lightPopupConfig.adMarkLabelBackgroundColor = $0 }
94
- setColorIfValid("closeButtonTextColor") { lightPopupConfig.closeButtonTextColor = $0 }
95
- setColorIfValid("titleTextColor") { lightPopupConfig.titleTextColor = $0 }
96
- setColorIfValid("bodyTextColor") { lightPopupConfig.bodyTextColor = $0 }
97
- setColorIfValid("ctaButtonTextColor") { lightPopupConfig.ctaButtonTextColor = $0 }
98
- setColorIfValid("ctaButtonBackgroundColor") { lightPopupConfig.ctaButtonBackgroundColor = $0 }
99
-
100
- if let closeButtonText = configuration["closeButtonText"] as? String {
101
- lightPopupConfig.closeButtonText = closeButtonText
102
- }
103
-
104
- ad.configuration = lightPopupConfig
105
- }
106
- }
107
-
108
- func retrieveLightPopupLoader(requestId: Int, adUnitId: String) -> DaroLightPopupAdLoader {
109
- if let lightPopupAd = lightPopups[requestId] {
110
- return lightPopupAd.loader
111
- } else {
112
- let lightPopupLoader = DaroLightPopupAdLoader(unit: DaroAdUnit(unitId: adUnitId))
113
-
114
- lightPopupLoader.listener.onAdClicked = { [weak self] adInfo in
115
- self?.sendEvent(with: .onLightPopupClickedEvent, body: adInfo?.toBody(requestId: requestId))
116
- }
117
-
118
- lightPopupLoader.listener.onAdImpression = { [weak self] adInfo in
119
- self?.lightPopups[requestId]?.loadedAd = nil
120
- self?.sendEvent(with: .onLightPopupAdImpressionRecordedEvent, body: adInfo?.toBody(requestId: requestId))
121
- }
122
-
123
- lightPopupLoader.listener.onAdLoadSuccess = { [weak self] ad, adInfo in
124
- self?.lightPopups[requestId]?.loadedAd = ad
125
- self?.sendEvent(with: .onLightPopupLoadedEvent, body: adInfo?.toBody(requestId: requestId))
126
- self?.setupLightPopupListener(for: ad, requestId: requestId)
127
- }
128
-
129
- lightPopupLoader.listener.onAdLoadFail = { [weak self] error in
130
- self?.sendEvent(with: .onLightPopupLoadFailedEvent, body: error.toBody(requestId: requestId))
131
- }
132
-
133
- self.lightPopups[requestId] = LightPopupAd(loader: lightPopupLoader)
134
- return lightPopupLoader
135
- }
136
- }
137
-
138
- private func setupLightPopupListener(for ad: DaroLightPopupAd, requestId: Int) {
139
- ad.lightPopupAdListener.onShown = { [weak self] adInfo in
140
- self?.sendEvent(with: .onLightPopupDisplayedEvent, body: adInfo?.toBody(requestId: requestId))
141
- }
142
-
143
- ad.lightPopupAdListener.onDismiss = { [weak self] adInfo in
144
- self?.sendEvent(with: .onLightPopupHiddenEvent, body: adInfo?.toBody(requestId: requestId))
145
- }
146
-
147
- ad.lightPopupAdListener.onFailedToShow = { [weak self] adInfo, error in
148
- self?.sendEvent(with: .onLightPopupAdFailedToDisplayEvent, body: adInfo?.toBody(requestId: requestId))
149
- }
150
- }
151
-
152
- // 메인 스레드에서 실행하는 헬퍼 메서드
153
- private func executeOnMainThread<T>(_ block: () -> T) -> T {
154
- if Thread.isMainThread {
155
- return block()
156
- } else {
157
- var result: T!
158
- DispatchQueue.main.sync {
159
- result = block()
160
- }
161
- return result
162
- }
163
- }
164
- }
165
-
166
- extension DaroLightPopupConfiguration {
167
- convenience init(from configuration: [String: Any]) {
168
- self.init()
169
- func setColorIfValid(_ key: String, setter: (UIColor) -> Void) {
170
- if let colorString = configuration[key] as? String {
171
- setter(UIColor(hex: colorString))
172
- }
173
- }
174
-
175
- setColorIfValid("backgroundColor") { self.backgroundColor = $0 }
176
- setColorIfValid("cardViewBackgroundColor") { self.cardViewBackgroundColor = $0 }
177
- setColorIfValid("adMarkLabelTextColor") { self.adMarkLabelTextColor = $0 }
178
- setColorIfValid("adMarkLabelBackgroundColor") { self.adMarkLabelBackgroundColor = $0 }
179
- setColorIfValid("closeButtonTextColor") { self.closeButtonTextColor = $0 }
180
- setColorIfValid("titleTextColor") { self.titleTextColor = $0 }
181
- setColorIfValid("bodyTextColor") { self.bodyTextColor = $0 }
182
- }
183
- }
@@ -1,207 +0,0 @@
1
- #import <React/RCTDefines.h>
2
-
3
- #ifdef RCT_NEW_ARCH_ENABLED
4
-
5
- #import <React/RCTComponent.h>
6
- #import <React/RCTFabricComponentsPlugins.h>
7
- #import <React/RCTViewComponentView.h>
8
- #import <react/renderer/components/DaroReactNativeSpec/ComponentDescriptors.h>
9
- #import <react/renderer/components/DaroReactNativeSpec/EventEmitters.h>
10
- #import <react/renderer/components/DaroReactNativeSpec/Props.h>
11
- #import <react/renderer/components/DaroReactNativeSpec/RCTComponentViewHelpers.h>
12
- #include <folly/dynamic.h>
13
- #include <string>
14
-
15
- using namespace facebook::react;
16
-
17
- extern UIView *DaroMFabricCreateSwiftView(NSString *className);
18
- extern void DaroMFabricSetValue(UIView *view, NSString *key, id value);
19
- extern void DaroMFabricPerformSelector(UIView *view, SEL selector);
20
- extern void DaroMFabricPerformSelectorWithObject(UIView *view, SEL selector, id object);
21
- extern NSString *DaroMFabricNSStringFromStdString(const std::string &value);
22
- extern NSDictionary *DaroMFabricEventBody(NSDictionary *body);
23
- extern std::string DaroMFabricEventString(NSDictionary *body, NSString *key);
24
- extern double DaroMFabricEventDouble(NSDictionary *body, NSString *key);
25
- extern int DaroMFabricEventInt(NSDictionary *body, NSString *key);
26
-
27
- @interface DaroMAdBannerViewComponentView : RCTViewComponentView <RCTDaroMAdBannerViewViewProtocol>
28
- @end
29
-
30
- @implementation DaroMAdBannerViewComponentView {
31
- UIView *_bannerView;
32
- }
33
-
34
- + (void)load
35
- {
36
- [super load];
37
- }
38
-
39
- - (instancetype)initWithFrame:(CGRect)frame
40
- {
41
- if (self = [super initWithFrame:frame]) {
42
- static const auto defaultProps = std::make_shared<const DaroMAdBannerViewProps>();
43
- _props = defaultProps;
44
- [self createBannerView];
45
- }
46
-
47
- return self;
48
- }
49
-
50
- - (void)createBannerView
51
- {
52
- _bannerView = DaroMFabricCreateSwiftView(@"DaroMAdBannerView");
53
- self.contentView = _bannerView;
54
- [self installEventHandlers];
55
- }
56
-
57
- - (void)installEventHandlers
58
- {
59
- __weak DaroMAdBannerViewComponentView *weakSelf = self;
60
-
61
- RCTDirectEventBlock onAdLoadedEvent = ^(NSDictionary *body) {
62
- DaroMAdBannerViewComponentView *strongSelf = weakSelf;
63
- if (!strongSelf) {
64
- return;
65
- }
66
-
67
- auto eventEmitter = std::static_pointer_cast<const DaroMAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
68
- if (!eventEmitter) {
69
- return;
70
- }
71
-
72
- NSDictionary *eventBody = DaroMFabricEventBody(body);
73
- eventEmitter->onAdLoadedEvent({
74
- .adUnitId = DaroMFabricEventString(eventBody, @"adUnitId"),
75
- .latencyMillis = DaroMFabricEventDouble(eventBody, @"latencyMillis"),
76
- });
77
- };
78
-
79
- RCTDirectEventBlock onAdLoadFailedEvent = ^(NSDictionary *body) {
80
- DaroMAdBannerViewComponentView *strongSelf = weakSelf;
81
- if (!strongSelf) {
82
- return;
83
- }
84
-
85
- auto eventEmitter = std::static_pointer_cast<const DaroMAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
86
- if (!eventEmitter) {
87
- return;
88
- }
89
-
90
- NSDictionary *eventBody = DaroMFabricEventBody(body);
91
- eventEmitter->onAdLoadFailedEvent({
92
- .adUnitId = DaroMFabricEventString(eventBody, @"adUnitId"),
93
- .code = DaroMFabricEventInt(eventBody, @"code"),
94
- .message = DaroMFabricEventString(eventBody, @"message"),
95
- .latencyMillis = DaroMFabricEventDouble(eventBody, @"latencyMillis"),
96
- });
97
- };
98
-
99
- RCTDirectEventBlock onAdClickedEvent = ^(NSDictionary *body) {
100
- DaroMAdBannerViewComponentView *strongSelf = weakSelf;
101
- if (!strongSelf) {
102
- return;
103
- }
104
-
105
- auto eventEmitter = std::static_pointer_cast<const DaroMAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
106
- if (!eventEmitter) {
107
- return;
108
- }
109
-
110
- NSDictionary *eventBody = DaroMFabricEventBody(body);
111
- eventEmitter->onAdClickedEvent({
112
- .adUnitId = DaroMFabricEventString(eventBody, @"adUnitId"),
113
- .latencyMillis = DaroMFabricEventDouble(eventBody, @"latencyMillis"),
114
- });
115
- };
116
-
117
- RCTDirectEventBlock onAdImpressionRecordedEvent = ^(NSDictionary *body) {
118
- DaroMAdBannerViewComponentView *strongSelf = weakSelf;
119
- if (!strongSelf) {
120
- return;
121
- }
122
-
123
- auto eventEmitter = std::static_pointer_cast<const DaroMAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
124
- if (!eventEmitter) {
125
- return;
126
- }
127
-
128
- NSDictionary *eventBody = DaroMFabricEventBody(body);
129
- eventEmitter->onAdImpressionRecordedEvent({
130
- .adUnitId = DaroMFabricEventString(eventBody, @"adUnitId"),
131
- .latencyMillis = DaroMFabricEventDouble(eventBody, @"latencyMillis"),
132
- });
133
- };
134
-
135
- DaroMFabricSetValue(_bannerView, @"onAdLoadedEvent", onAdLoadedEvent);
136
- DaroMFabricSetValue(_bannerView, @"onAdLoadFailedEvent", onAdLoadFailedEvent);
137
- DaroMFabricSetValue(_bannerView, @"onAdClickedEvent", onAdClickedEvent);
138
- DaroMFabricSetValue(_bannerView, @"onAdImpressionRecordedEvent", onAdImpressionRecordedEvent);
139
- }
140
-
141
- + (ComponentDescriptorProvider)componentDescriptorProvider
142
- {
143
- return concreteComponentDescriptorProvider<DaroMAdBannerViewComponentDescriptor>();
144
- }
145
-
146
- - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
147
- {
148
- const auto &oldComponentProps = *std::static_pointer_cast<const DaroMAdBannerViewProps>(_props);
149
- const auto &newComponentProps = *std::static_pointer_cast<const DaroMAdBannerViewProps>(props);
150
- NSMutableArray<NSString *> *changedProps = [NSMutableArray new];
151
-
152
- if (oldComponentProps.adUnitId != newComponentProps.adUnitId) {
153
- DaroMFabricSetValue(_bannerView, @"adUnitId", DaroMFabricNSStringFromStdString(newComponentProps.adUnitId));
154
- [changedProps addObject:@"adUnitId"];
155
- }
156
-
157
- if (oldComponentProps.adFormat != newComponentProps.adFormat) {
158
- DaroMFabricSetValue(_bannerView, @"adFormat", DaroMFabricNSStringFromStdString(newComponentProps.adFormat));
159
- [changedProps addObject:@"adFormat"];
160
- }
161
-
162
- if (oldComponentProps.loadOnMount != newComponentProps.loadOnMount) {
163
- DaroMFabricSetValue(_bannerView, @"loadOnMount", @(newComponentProps.loadOnMount));
164
- [changedProps addObject:@"loadOnMount"];
165
- }
166
-
167
- if (oldComponentProps.isVisible != newComponentProps.isVisible) {
168
- DaroMFabricSetValue(_bannerView, @"isVisible", @(newComponentProps.isVisible));
169
- [changedProps addObject:@"isVisible"];
170
- }
171
-
172
- [super updateProps:props oldProps:oldProps];
173
-
174
- DaroMFabricPerformSelectorWithObject(_bannerView, NSSelectorFromString(@"applyReactProps:"), changedProps);
175
- }
176
-
177
- - (void)loadAd
178
- {
179
- DaroMFabricPerformSelector(_bannerView, NSSelectorFromString(@"loadAd"));
180
- }
181
-
182
- - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
183
- {
184
- RCTDaroMAdBannerViewHandleCommand(self, commandName, args);
185
- }
186
-
187
- - (void)prepareForRecycle
188
- {
189
- [super prepareForRecycle];
190
- DaroMFabricSetValue(_bannerView, @"onAdLoadedEvent", nil);
191
- DaroMFabricSetValue(_bannerView, @"onAdLoadFailedEvent", nil);
192
- DaroMFabricSetValue(_bannerView, @"onAdClickedEvent", nil);
193
- DaroMFabricSetValue(_bannerView, @"onAdImpressionRecordedEvent", nil);
194
- DaroMFabricPerformSelector(_bannerView, NSSelectorFromString(@"prepareForReuse"));
195
- [self installEventHandlers];
196
- static const auto defaultProps = std::make_shared<const DaroMAdBannerViewProps>();
197
- _props = defaultProps;
198
- }
199
-
200
- @end
201
-
202
- Class<RCTComponentViewProtocol> DaroMAdBannerViewCls(void)
203
- {
204
- return DaroMAdBannerViewComponentView.class;
205
- }
206
-
207
- #endif