react-native-daro 1.0.15 → 2.0.0-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.
Files changed (241) hide show
  1. package/README.md +2 -5
  2. package/android/build.gradle +17 -14
  3. package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
  4. package/android/src/main/java/com/daro/reactnative/DaroRNAdBannerViewManager.kt +105 -0
  5. package/android/src/main/java/com/daro/reactnative/DaroRNAdNativeViewManager.kt +163 -0
  6. package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +376 -0
  7. package/android/src/main/java/com/daro/reactnative/DaroRNPackage.kt +45 -0
  8. package/android/src/main/java/com/daro/reactnative/DaroSdkBridge.kt +52 -0
  9. package/android/src/main/java/com/daro/reactnative/constants/{InternalDaroMBannerSize.kt → InternalDaroRNBannerSize.kt} +2 -2
  10. package/android/src/main/java/com/daro/reactnative/event/{DaroMEvent.kt → DaroRNEvent.kt} +22 -11
  11. package/android/src/main/java/com/daro/reactnative/impl/{DaroMBannerViewModuleImpl.kt → DaroRNBannerViewModuleImpl.kt} +3 -3
  12. package/android/src/main/java/com/daro/reactnative/impl/{DaroMInterstitialModuleImpl.kt → DaroRNInterstitialModuleImpl.kt} +4 -4
  13. package/android/src/main/java/com/daro/reactnative/impl/{DaroMLightPopupModuleImpl.kt → DaroRNLightPopupModuleImpl.kt} +4 -4
  14. package/android/src/main/java/com/daro/reactnative/impl/{DaroMRewardedAdModuleImpl.kt → DaroRNRewardedAdModuleImpl.kt} +4 -4
  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 +20 -7
  18. package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +123 -0
  19. package/android/src/main/java/com/daro/reactnative/view/{DaroMAdBannerViewContainer.kt → DaroRNAdBannerViewContainer.kt} +2 -3
  20. package/android/src/main/java/com/daro/reactnative/view/DaroRNAdNativeViewContainer.kt +623 -0
  21. package/android/src/newarch/java/com/daro/reactnative/DaroRNModuleSpec.kt +6 -0
  22. package/android/src/oldarch/java/com/daro/reactnative/DaroRNModuleSpec.kt +119 -0
  23. package/ios/{DaroMModule+AppOpen.swift → DaroRNModule+AppOpen.swift} +22 -20
  24. package/ios/DaroRNModule+Consent.swift +88 -0
  25. package/ios/{DaroMModule+Interstitial.swift → DaroRNModule+Interstitial.swift} +21 -18
  26. package/ios/{DaroMModule+LightPopup.swift → DaroRNModule+LightPopup.swift} +18 -15
  27. package/ios/DaroRNModule+Qa.swift +158 -0
  28. package/ios/{DaroMModule+Rewarded.swift → DaroRNModule+Rewarded.swift} +22 -19
  29. package/ios/DaroRNModule.mm +88 -0
  30. package/ios/{DaroMModule.swift → DaroRNModule.swift} +24 -10
  31. package/ios/Fabric/DaroRNAdBannerComponentView.mm +219 -0
  32. package/ios/Fabric/DaroRNFabricEventSink.mm +31 -0
  33. package/ios/Fabric/DaroRNFabricPropApplier.mm +123 -0
  34. package/ios/Fabric/DaroRNNativeAdComponentView.mm +306 -0
  35. package/ios/{DaroMAdBannerViewManager.m → Paper/DaroRNAdBannerViewManager.m} +4 -2
  36. package/ios/Paper/DaroRNAdBannerViewManager.swift +21 -0
  37. package/ios/{DaroMNativeAdViewManager.m → Paper/DaroRNNativeAdViewManager.m} +3 -2
  38. package/ios/Paper/DaroRNNativeAdViewManager.swift +22 -0
  39. package/ios/Shared/DaroMediationDebugger.swift +14 -0
  40. package/ios/{mediation/admob → Shared}/DaroMediationTypes.swift +1 -0
  41. package/ios/Shared/DaroRNAdEventSink.swift +24 -0
  42. package/ios/Shared/DaroRNBannerAdView.swift +188 -0
  43. package/ios/Shared/DaroRNNativeAdLoadCoordinator.swift +49 -0
  44. package/ios/Shared/DaroRNNativeAdView.swift +575 -0
  45. package/ios/Shared/DaroRNNativeAssetResolver.swift +53 -0
  46. package/lib/commonjs/AdBannerView.js +20 -41
  47. package/lib/commonjs/AdBannerView.js.map +1 -1
  48. package/lib/commonjs/AppOpenAd.js +45 -12
  49. package/lib/commonjs/AppOpenAd.js.map +1 -1
  50. package/lib/commonjs/DaroMediaViewNativeComponent.ts +9 -0
  51. package/lib/commonjs/DaroRNAdBannerViewNativeComponent.ts +50 -0
  52. package/lib/commonjs/DaroRNNativeAdViewNativeComponent.ts +65 -0
  53. package/lib/commonjs/EventEmitter.js +4 -5
  54. package/lib/commonjs/EventEmitter.js.map +1 -1
  55. package/lib/commonjs/InterstitialAd.js +9 -11
  56. package/lib/commonjs/InterstitialAd.js.map +1 -1
  57. package/lib/commonjs/LightPopupAd.js +11 -12
  58. package/lib/commonjs/LightPopupAd.js.map +1 -1
  59. package/lib/commonjs/NativeDaroModule.js +9 -0
  60. package/lib/commonjs/NativeDaroModule.js.map +1 -0
  61. package/lib/commonjs/RewardedAd.js +9 -11
  62. package/lib/commonjs/RewardedAd.js.map +1 -1
  63. package/lib/commonjs/codegen-env.d.js +2 -0
  64. package/lib/commonjs/codegen-env.d.js.map +1 -0
  65. package/lib/commonjs/hooks/useInterstitialAd.js +110 -0
  66. package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
  67. package/lib/commonjs/hooks/useLightPopupAd.js +114 -0
  68. package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -0
  69. package/lib/commonjs/hooks/useRewardedAd.js +113 -0
  70. package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
  71. package/lib/commonjs/index.js +150 -13
  72. package/lib/commonjs/index.js.map +1 -1
  73. package/lib/commonjs/nativeAd/NativeAdView.js +23 -22
  74. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
  75. package/lib/commonjs/nativeAd/NativeAdViewComponents.js +43 -31
  76. package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
  77. package/lib/commonjs/nativeAd/NativeAdViewProvider.js +34 -7
  78. package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
  79. package/lib/module/AdBannerView.js +19 -42
  80. package/lib/module/AdBannerView.js.map +1 -1
  81. package/lib/module/AppOpenAd.js +45 -13
  82. package/lib/module/AppOpenAd.js.map +1 -1
  83. package/lib/module/DaroMediaViewNativeComponent.ts +9 -0
  84. package/lib/module/DaroRNAdBannerViewNativeComponent.ts +50 -0
  85. package/lib/module/DaroRNNativeAdViewNativeComponent.ts +65 -0
  86. package/lib/module/EventEmitter.js +4 -6
  87. package/lib/module/EventEmitter.js.map +1 -1
  88. package/lib/module/InterstitialAd.js +8 -11
  89. package/lib/module/InterstitialAd.js.map +1 -1
  90. package/lib/module/LightPopupAd.js +11 -13
  91. package/lib/module/LightPopupAd.js.map +1 -1
  92. package/lib/module/NativeDaroModule.js +5 -0
  93. package/lib/module/NativeDaroModule.js.map +1 -0
  94. package/lib/module/RewardedAd.js +8 -11
  95. package/lib/module/RewardedAd.js.map +1 -1
  96. package/lib/module/codegen-env.d.js +2 -0
  97. package/lib/module/codegen-env.d.js.map +1 -0
  98. package/lib/module/hooks/useInterstitialAd.js +106 -0
  99. package/lib/module/hooks/useInterstitialAd.js.map +1 -0
  100. package/lib/module/hooks/useLightPopupAd.js +110 -0
  101. package/lib/module/hooks/useLightPopupAd.js.map +1 -0
  102. package/lib/module/hooks/useRewardedAd.js +109 -0
  103. package/lib/module/hooks/useRewardedAd.js.map +1 -0
  104. package/lib/module/index.js +108 -13
  105. package/lib/module/index.js.map +1 -1
  106. package/lib/module/nativeAd/NativeAdView.js +22 -23
  107. package/lib/module/nativeAd/NativeAdView.js.map +1 -1
  108. package/lib/module/nativeAd/NativeAdViewComponents.js +45 -34
  109. package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
  110. package/lib/module/nativeAd/NativeAdViewProvider.js +35 -8
  111. package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
  112. package/lib/typescript/commonjs/plugin/src/index.d.ts +2 -6
  113. package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +2 -6
  115. package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/plugin/src/withIos.d.ts +2 -6
  117. package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/AdBannerView.d.ts +2 -2
  119. package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/AppOpenAd.d.ts +2 -2
  121. package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts +6 -0
  123. package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts +33 -0
  125. package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
  126. package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts +43 -0
  127. package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
  128. package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
  130. package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +70 -0
  132. package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -0
  133. package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +19 -0
  135. package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +23 -0
  137. package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +20 -0
  139. package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/src/index.d.ts +86 -1
  141. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +1 -0
  143. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
  146. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/types/AdInfo.d.ts +15 -0
  148. package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/types/AdProps.d.ts +0 -1
  150. package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +2 -0
  152. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
  153. package/lib/typescript/module/plugin/src/index.d.ts +2 -6
  154. package/lib/typescript/module/plugin/src/index.d.ts.map +1 -1
  155. package/lib/typescript/module/plugin/src/withAndroid.d.ts +2 -6
  156. package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -1
  157. package/lib/typescript/module/plugin/src/withIos.d.ts +2 -6
  158. package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -1
  159. package/lib/typescript/module/src/AdBannerView.d.ts +2 -2
  160. package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
  161. package/lib/typescript/module/src/AppOpenAd.d.ts +2 -2
  162. package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
  163. package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts +6 -0
  164. package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
  165. package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts +33 -0
  166. package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
  167. package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts +43 -0
  168. package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
  169. package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -1
  170. package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
  171. package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
  172. package/lib/typescript/module/src/NativeDaroModule.d.ts +70 -0
  173. package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -0
  174. package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
  175. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +19 -0
  176. package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -0
  177. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +23 -0
  178. package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -0
  179. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +20 -0
  180. package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -0
  181. package/lib/typescript/module/src/index.d.ts +86 -1
  182. package/lib/typescript/module/src/index.d.ts.map +1 -1
  183. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +1 -0
  184. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
  185. package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
  186. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
  187. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
  188. package/lib/typescript/module/src/types/AdInfo.d.ts +15 -0
  189. package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
  190. package/lib/typescript/module/src/types/AdProps.d.ts +0 -1
  191. package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
  192. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +2 -0
  193. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
  194. package/package.json +12 -5
  195. package/plugin/build/index.d.ts +2 -6
  196. package/plugin/build/index.js +21 -56
  197. package/plugin/build/withAndroid.d.ts +2 -6
  198. package/plugin/build/withAndroid.js +123 -83
  199. package/plugin/build/withIos.d.ts +2 -6
  200. package/plugin/build/withIos.js +37 -34
  201. package/react-native-daro.podspec +4 -2
  202. package/src/AdBannerView.tsx +24 -63
  203. package/src/AppOpenAd.ts +48 -17
  204. package/src/DaroMediaViewNativeComponent.ts +9 -0
  205. package/src/DaroRNAdBannerViewNativeComponent.ts +50 -0
  206. package/src/DaroRNNativeAdViewNativeComponent.ts +65 -0
  207. package/src/EventEmitter.ts +4 -5
  208. package/src/InterstitialAd.ts +8 -10
  209. package/src/LightPopupAd.ts +11 -12
  210. package/src/NativeDaroModule.ts +106 -0
  211. package/src/RewardedAd.ts +8 -10
  212. package/src/codegen-env.d.ts +45 -0
  213. package/src/hooks/useInterstitialAd.ts +117 -0
  214. package/src/hooks/useLightPopupAd.ts +132 -0
  215. package/src/hooks/useRewardedAd.ts +122 -0
  216. package/src/index.tsx +157 -22
  217. package/src/nativeAd/NativeAdView.tsx +41 -54
  218. package/src/nativeAd/NativeAdViewComponents.tsx +80 -42
  219. package/src/nativeAd/NativeAdViewProvider.tsx +75 -17
  220. package/src/types/AdInfo.ts +17 -0
  221. package/src/types/AdProps.ts +0 -2
  222. package/src/types/NativeAdViewProps.ts +7 -0
  223. package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +0 -23
  224. package/android/src/main/java/com/daro/reactnative/DaroMAdBannerViewManager.kt +0 -132
  225. package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +0 -136
  226. package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +0 -202
  227. package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +0 -21
  228. package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +0 -375
  229. package/ios/DaroMAdBannerViewManager.swift +0 -91
  230. package/ios/DaroMModule.mm +0 -45
  231. package/ios/DaroMNativeAdViewManager.swift +0 -291
  232. package/ios/mediation/admob/DaroMediationDebugger.swift +0 -11
  233. package/lib/commonjs/types/DaroMMobileAds.js +0 -2
  234. package/lib/commonjs/types/DaroMMobileAds.js.map +0 -1
  235. package/lib/module/types/DaroMMobileAds.js +0 -2
  236. package/lib/module/types/DaroMMobileAds.js.map +0 -1
  237. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts +0 -6
  238. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +0 -1
  239. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts +0 -6
  240. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +0 -1
  241. package/src/types/DaroMMobileAds.ts +0 -5
@@ -1,132 +0,0 @@
1
- package com.daro.reactnative
2
-
3
- import com.daro.reactnative.constants.InternalDaroMBannerSize
4
- import com.daro.reactnative.event.AdViewEvent
5
- import com.daro.reactnative.view.DaroMAdBannerViewContainer
6
- import com.facebook.react.bridge.ReadableArray
7
- import com.facebook.react.uimanager.ReactStylesDiffMap
8
- import com.facebook.react.uimanager.SimpleViewManager
9
- import com.facebook.react.uimanager.StateWrapper
10
- import com.facebook.react.uimanager.ThemedReactContext
11
- import com.facebook.react.uimanager.annotations.ReactProp
12
-
13
- class DaroMAdBannerViewManager : SimpleViewManager<DaroMAdBannerViewContainer>() {
14
-
15
- override fun getName(): String {
16
- return "DaroMAdBannerView"
17
- }
18
-
19
- companion object {
20
- private const val COMMAND_LOAD_AD: Int = 1
21
-
22
- private val viewCache: MutableMap<String, DaroMAdBannerViewContainer> = mutableMapOf()
23
- }
24
-
25
- override fun createViewInstance(
26
- reactTag: Int,
27
- reactContext: ThemedReactContext,
28
- initialProps: ReactStylesDiffMap?,
29
- stateWrapper: StateWrapper?,
30
- ): DaroMAdBannerViewContainer {
31
- val placement = initialProps?.getString("placement")
32
- val adUnitId = initialProps?.getString("adUnitId")
33
-
34
- val cacheKey = when {
35
- adUnitId.isNullOrBlank() || placement.isNullOrBlank() -> ""
36
- else -> "{$adUnitId}_${placement}${reactContext.hashCode()}"
37
- }
38
-
39
- if (cacheKey.isNotBlank()) {
40
- viewCache.keys
41
- .filter { it.contains(cacheKey) && it != cacheKey }
42
- .forEach { viewCache.remove(it)?.destroy() }
43
- }
44
-
45
- return cacheKey.let {
46
- viewCache[cacheKey].let { cachedView ->
47
- cachedView?.id = reactTag
48
-
49
- if(cachedView?.parent == null) {
50
- cachedView?.resumeAd()
51
- cachedView
52
- } else {
53
- null
54
- }
55
- }
56
- } ?: super.createViewInstance(reactTag, reactContext, initialProps, stateWrapper).also { view ->
57
- if (cacheKey.isNotBlank()) viewCache[cacheKey] = view
58
- }
59
- }
60
-
61
- override fun createViewInstance(reactContext: ThemedReactContext): DaroMAdBannerViewContainer {
62
- return DaroMAdBannerViewContainer(reactContext).apply {
63
- loadOnMount = true
64
- }
65
- }
66
-
67
- override fun getCommandsMap(): MutableMap<String, Int> {
68
- return mutableMapOf(
69
- "loadAd" to COMMAND_LOAD_AD,
70
- )
71
- }
72
-
73
- override fun onAfterUpdateTransaction(view: DaroMAdBannerViewContainer) {
74
- super.onAfterUpdateTransaction(view)
75
- view.onSetProps()
76
- }
77
-
78
- override fun onDropViewInstance(view: DaroMAdBannerViewContainer) {
79
- super.onDropViewInstance(view)
80
-
81
- val isCached = viewCache.values.contains(view)
82
- if (isCached) {
83
- view.pauseAd()
84
- } else {
85
- view.destroy()
86
- }
87
- }
88
-
89
- @Deprecated("")
90
- override fun receiveCommand(
91
- root: DaroMAdBannerViewContainer,
92
- commandId: Int,
93
- args: ReadableArray?,
94
- ) {
95
- when (commandId) {
96
- COMMAND_LOAD_AD -> {
97
- root.loadAd()
98
- }
99
- }
100
- }
101
-
102
- @ReactProp(name = "isVisible")
103
- fun setIsVisible(view: DaroMAdBannerViewContainer, isVisible: Boolean) {
104
- view.setAdVisibility(isVisible)
105
- }
106
-
107
- @ReactProp(name = "adUnitId")
108
- fun setAdUnitId(view: DaroMAdBannerViewContainer, adUnitId: String) {
109
- view.adUnitId = adUnitId
110
- }
111
-
112
- @ReactProp(name = "adFormat")
113
- fun setAdFormat(view: DaroMAdBannerViewContainer, adFormat: String) {
114
- view.adSize = InternalDaroMBannerSize.fromName(adFormat).toBannerSize()
115
- }
116
-
117
- @ReactProp(name = "loadOnMount")
118
- fun setLoadOnMount(view: DaroMAdBannerViewContainer, loadOnMount: Boolean) {
119
- view.loadOnMount = loadOnMount
120
- }
121
-
122
- @ReactProp(name = "placement")
123
- fun setPlacement(view: DaroMAdBannerViewContainer, placement: String) {
124
- }
125
-
126
- @OptIn(ExperimentalStdlibApi::class)
127
- override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
128
- return AdViewEvent.entries.associate {
129
- it.value to mutableMapOf("phasedRegistrationNames" to mutableMapOf("bubbled" to it.key))
130
- }.toMutableMap()
131
- }
132
- }
@@ -1,136 +0,0 @@
1
- package com.daro.reactnative
2
-
3
- import com.daro.reactnative.event.AdViewEvent
4
- import com.daro.reactnative.view.DaroMAdBannerViewContainer
5
- import com.daro.reactnative.view.DaroMAdNativeViewContainer
6
- import com.facebook.react.bridge.ReadableArray
7
- import com.facebook.react.uimanager.ReactStylesDiffMap
8
- import com.facebook.react.uimanager.StateWrapper
9
- import com.facebook.react.uimanager.ThemedReactContext
10
- import com.facebook.react.uimanager.ViewGroupManager
11
- import com.facebook.react.uimanager.annotations.ReactProp
12
-
13
- class DaroMAdNativeViewManager : ViewGroupManager<DaroMAdNativeViewContainer>() {
14
-
15
- override fun getName(): String {
16
- return "DaroMNativeAdView"
17
- }
18
-
19
- override fun createViewInstance(
20
- reactTag: Int,
21
- reactContext: ThemedReactContext,
22
- initialProps: ReactStylesDiffMap?,
23
- stateWrapper: StateWrapper?,
24
- ): DaroMAdNativeViewContainer {
25
- val placement = initialProps?.getString("placement")
26
- val adUnitId = initialProps?.getString("adUnitId")
27
-
28
- val key = "{$adUnitId}_${placement}"
29
-
30
- if (key.isNotEmpty()) {
31
- viewCache.keys.firstOrNull { it.contains(key) }?.let {
32
- if (it != key + reactContext.hashCode()) {
33
- viewCache.remove(it)
34
- }
35
- }
36
- }
37
-
38
- return key.let {
39
- viewCache[it + reactContext.hashCode()].let { view ->
40
- view?.id = reactTag
41
-
42
- if(view?.parent == null) view.also {
43
- it?.applyPrevSetting()
44
- }
45
-
46
- else null
47
- }
48
- } ?: super.createViewInstance(reactTag, reactContext, initialProps, stateWrapper).also {
49
- if (key.isNotEmpty()) viewCache[key + reactContext.hashCode()] = it
50
- }
51
- }
52
-
53
- override fun createViewInstance(context: ThemedReactContext): DaroMAdNativeViewContainer {
54
- return DaroMAdNativeViewContainer(context)
55
- }
56
-
57
- companion object {
58
- private const val COMMAND_LOAD_AD: Int = 1
59
-
60
- private val viewCache: MutableMap<String, DaroMAdNativeViewContainer> = mutableMapOf()
61
- }
62
-
63
- override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
64
- return AdViewEvent.entries.associate {
65
- it.value to mutableMapOf("phasedRegistrationNames" to mutableMapOf("bubbled" to it.key))
66
- }.toMutableMap()
67
- }
68
-
69
- override fun getCommandsMap(): MutableMap<String, Int> {
70
- return mutableMapOf(
71
- "loadAd" to COMMAND_LOAD_AD,
72
- )
73
- }
74
-
75
- @Deprecated("")
76
- override fun receiveCommand(
77
- root: DaroMAdNativeViewContainer,
78
- commandId: Int,
79
- args: ReadableArray?,
80
- ) {
81
- when (commandId) {
82
- COMMAND_LOAD_AD -> {
83
- root.loadAd()
84
- }
85
- }
86
- }
87
-
88
- @ReactProp(name = "adUnitId")
89
- fun setAdUnitId(view: DaroMAdNativeViewContainer, adUnitId: String) {
90
- view.adUnitId = adUnitId
91
- }
92
-
93
- @ReactProp(name = "loadOnMount")
94
- fun setLoadOnMount(view: DaroMAdNativeViewContainer, loadOnMount: Boolean) {
95
- view.loadOnMount = loadOnMount
96
- }
97
-
98
- @ReactProp(name = "titleView")
99
- fun setTitleView(view: DaroMAdNativeViewContainer, value: Int) {
100
- view.setTitleView(value)
101
- }
102
-
103
- @ReactProp(name = "bodyView")
104
- fun setBodyView(view: DaroMAdNativeViewContainer, value: Int) {
105
- view.setBodyView(value)
106
- }
107
-
108
- @ReactProp(name = "callToActionView")
109
- fun setCallToActionView(view: DaroMAdNativeViewContainer, value: Int) {
110
- view.setCallToActionView(value)
111
- }
112
-
113
- @ReactProp(name = "iconView")
114
- fun setIconView(view: DaroMAdNativeViewContainer, value: Int) {
115
- view.setIconView(value)
116
- }
117
-
118
- @ReactProp(name = "mediaView")
119
- fun setMediaView(view: DaroMAdNativeViewContainer, value: Int) {
120
- view.setMediaView(value)
121
- }
122
-
123
- @ReactProp(name = "placement")
124
- fun setPlacement(view: DaroMAdBannerViewContainer, placement: String) {
125
- }
126
-
127
- override fun onAfterUpdateTransaction(view: DaroMAdNativeViewContainer) {
128
- super.onAfterUpdateTransaction(view)
129
- view.onSetProps()
130
- }
131
-
132
- override fun onDropViewInstance(view: DaroMAdNativeViewContainer) {
133
- super.onDropViewInstance(view)
134
- // view.destroy()
135
- }
136
- }
@@ -1,202 +0,0 @@
1
- package com.daro.reactnative
2
-
3
- import android.app.Application
4
- import android.content.Context
5
- import com.daro.reactnative.constants.InternalDaroMBannerSize
6
- import com.daro.reactnative.event.DaroMEvent
7
- import com.daro.reactnative.event.InterstitialEvent
8
- import com.daro.reactnative.event.LightPopupEvent
9
- import com.daro.reactnative.event.RewardedEvent
10
- import com.daro.reactnative.impl.DaroMBannerViewModuleImpl
11
- import com.daro.reactnative.impl.DaroMInterstitialModuleImpl
12
- import com.daro.reactnative.impl.DaroMLightPopupModuleImpl
13
- import com.daro.reactnative.impl.DaroMRewardedAdModuleImpl
14
- import com.daro.reactnative.util.EventEmitterUtil
15
- import com.facebook.react.bridge.Promise
16
- import com.facebook.react.bridge.ReactApplicationContext
17
- import com.facebook.react.bridge.ReactContext
18
- import com.facebook.react.bridge.ReactContextBaseJavaModule
19
- import com.facebook.react.bridge.ReactMethod
20
- import com.facebook.react.bridge.ReadableMap
21
- import com.facebook.react.bridge.WritableMap
22
- import droom.daro.SDKConfig
23
-
24
- class DaroMModule(reactContext: ReactApplicationContext) :
25
- ReactContextBaseJavaModule(reactContext) {
26
-
27
- companion object {
28
- const val NAME = "DaroMModule"
29
- }
30
-
31
- override fun getName(): String {
32
- return NAME
33
- }
34
-
35
- private val context: Context = reactApplicationContext
36
-
37
- private var isInitialized: Boolean = false
38
-
39
- @ReactMethod
40
- fun initializeSdk() {
41
- DaroSdkBridge.initialize(
42
- application = context.applicationContext as Application,
43
- sdkConfig = SDKConfig.Builder()
44
- .setDebugMode(false)
45
- .build()
46
- )
47
-
48
- isInitialized = true
49
- }
50
-
51
- @ReactMethod
52
- fun isInitialized(promise: Promise) {
53
- promise.resolve(isInitialized)
54
- }
55
-
56
- @ReactMethod
57
- fun showMediationDebugger() {
58
- DaroSdkBridge.openDebugger(context)
59
- }
60
-
61
- @ReactMethod
62
- fun setUserId(userId: String) {
63
- DaroSdkBridge.setUserId(context, userId)
64
- }
65
-
66
- override fun getConstants(): MutableMap<String, Any>? {
67
- val constants = mutableMapOf<String, Any>()
68
- constants.putAll(daroMInterstitialModule.getComponents())
69
- constants.putAll(daroMRewardedModule.getComponents())
70
- constants.putAll(daroMLightPopupModule.getComponents())
71
- constants.putAll(daroMBannerModule.getComponents())
72
-
73
- return constants
74
- }
75
-
76
- internal abstract class DaroMComponentModule(protected val context: ReactContext) {
77
- abstract fun getComponents(): MutableMap<String, Any>
78
-
79
- fun sendNativeEvent(event: DaroMEvent, params: WritableMap?) {
80
- EventEmitterUtil.sendReactNativeEvent(
81
- reactContext = context,
82
- event = event,
83
- params = params,
84
- )
85
- }
86
- }
87
-
88
- @OptIn(ExperimentalStdlibApi::class)
89
- internal abstract class DaroMInterstitialModule(context: ReactContext) :
90
- DaroMComponentModule(context) {
91
- abstract fun isInterstitialReady(requestId: Int, adUnitId: String, promise: Promise)
92
- abstract fun loadInterstitial(requestId: Int, adUnitId: String)
93
- abstract fun showInterstitial(requestId: Int, adUnitId: String)
94
-
95
- override fun getComponents(): MutableMap<String, Any> {
96
- return InterstitialEvent.entries.associate { it.value to it.value }.toMutableMap()
97
- }
98
- }
99
-
100
- private val daroMInterstitialModule: DaroMInterstitialModule =
101
- DaroMInterstitialModuleImpl(
102
- context = reactContext,
103
- getCurrentActivity = { getCurrentActivity() }
104
- )
105
-
106
- @ReactMethod
107
- fun isInterstitialReady(requestId: Double, adUnitId: String, promise: Promise) {
108
- daroMInterstitialModule.isInterstitialReady(requestId.toInt(), adUnitId, promise)
109
- }
110
-
111
- @ReactMethod
112
- fun loadInterstitial(requestId: Double, adUnitId: String) {
113
- daroMInterstitialModule.loadInterstitial(requestId.toInt(), adUnitId)
114
- }
115
-
116
- @ReactMethod
117
- fun showInterstitial(requestId: Double, adUnitId: String) {
118
- daroMInterstitialModule.showInterstitial(requestId.toInt(), adUnitId)
119
- }
120
-
121
- @OptIn(ExperimentalStdlibApi::class)
122
- internal abstract class DaroMRewardedModule(context: ReactContext) :
123
- DaroMComponentModule(context) {
124
- abstract fun isRewardedAdReady(requestId: Int, adUnitId: String, promise: Promise)
125
- abstract fun loadRewardedAd(requestId: Int, adUnitId: String)
126
- abstract fun showRewardedAd(requestId: Int, adUnitId: String, customData: String?)
127
-
128
- override fun getComponents(): MutableMap<String, Any> {
129
- return RewardedEvent.entries.associate { it.value to it.value }.toMutableMap()
130
- }
131
- }
132
-
133
- private val daroMRewardedModule: DaroMRewardedModule =
134
- DaroMRewardedAdModuleImpl(
135
- context = reactContext,
136
- getCurrentActivity = { getCurrentActivity() }
137
- )
138
-
139
- @ReactMethod
140
- fun isRewardedAdReady(requestId: Double, adUnitId: String, promise: Promise) {
141
- daroMRewardedModule.isRewardedAdReady(requestId.toInt(), adUnitId, promise)
142
- }
143
-
144
- @ReactMethod
145
- fun loadRewardedAd(requestId: Double, adUnitId: String) {
146
- daroMRewardedModule.loadRewardedAd(requestId.toInt(), adUnitId)
147
- }
148
-
149
- @ReactMethod
150
- fun showRewardedAd(requestId: Double, adUnitId: String, customData: String?) {
151
- daroMRewardedModule.showRewardedAd(requestId.toInt(), adUnitId, customData)
152
- }
153
-
154
- @OptIn(ExperimentalStdlibApi::class)
155
- internal abstract class DaroMLightPopupModule(context: ReactContext) :
156
- DaroMComponentModule(context) {
157
- abstract fun isLightPopupReady(requestId: Int, adUnitId: String, promise: Promise)
158
- abstract fun loadLightPopup(requestId: Int, adUnitId: String)
159
- abstract fun showLightPopup(requestId: Int, adUnitId: String)
160
-
161
- abstract fun setLightPopupAdConfiguration(requestId: Int, adUnitId: String, parameterMap: ReadableMap)
162
-
163
- override fun getComponents(): MutableMap<String, Any> {
164
- return LightPopupEvent.entries.associate { it.value to it.value }.toMutableMap()
165
- }
166
- }
167
-
168
- private val daroMLightPopupModule: DaroMLightPopupModule = DaroMLightPopupModuleImpl(
169
- context = reactContext,
170
- getCurrentActivity = { getCurrentActivity() }
171
- )
172
-
173
- @ReactMethod
174
- fun isLightPopupReady(requestId: Double, adUnitId: String, promise: Promise) {
175
- daroMLightPopupModule.isLightPopupReady(requestId.toInt(), adUnitId, promise)
176
- }
177
-
178
- @ReactMethod
179
- fun loadLightPopup(requestId: Double, adUnitId: String) {
180
- daroMLightPopupModule.loadLightPopup(requestId.toInt(), adUnitId)
181
- }
182
-
183
- @ReactMethod
184
- fun showLightPopup(requestId: Double, adUnitId: String) {
185
- daroMLightPopupModule.showLightPopup(requestId.toInt(), adUnitId)
186
- }
187
-
188
- @ReactMethod
189
- fun setLightPopupAdConfiguration(requestId: Double, adUnitId: String, configurationMap: ReadableMap) {
190
- daroMLightPopupModule.setLightPopupAdConfiguration(requestId.toInt(), adUnitId, configurationMap)
191
- }
192
-
193
- @OptIn(ExperimentalStdlibApi::class)
194
- internal abstract class DaroMBannerModule(context: ReactContext) : DaroMComponentModule(context) {
195
- override fun getComponents(): MutableMap<String, Any> {
196
- return InternalDaroMBannerSize.entries.associate { it.key to it.name }.toMutableMap()
197
- }
198
- }
199
-
200
- private val daroMBannerModule: DaroMBannerModule =
201
- DaroMBannerViewModuleImpl(context = reactContext)
202
- }
@@ -1,21 +0,0 @@
1
- package com.daro.reactnative
2
-
3
- import com.facebook.react.ReactPackage
4
- import com.facebook.react.bridge.NativeModule
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.ViewManager
7
-
8
-
9
- class DaroMPackage : ReactPackage {
10
-
11
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
12
- return listOf(DaroMModule(reactContext))
13
- }
14
-
15
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
16
- return listOf(
17
- DaroMAdBannerViewManager(),
18
- DaroMAdNativeViewManager(),
19
- )
20
- }
21
- }