react-native-daro 1.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 (245) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +47 -0
  3. package/android/build.gradle +99 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +7 -0
  7. package/android/src/main/java/com/darom/DaroMAdBannerViewManager.kt +114 -0
  8. package/android/src/main/java/com/darom/DaroMAdNativeViewManager.kt +133 -0
  9. package/android/src/main/java/com/darom/DaroMModule.kt +194 -0
  10. package/android/src/main/java/com/darom/DaroMPackage.kt +21 -0
  11. package/android/src/main/java/com/darom/constants/InternalDaroMBannerSize.kt +23 -0
  12. package/android/src/main/java/com/darom/event/DaroMEvent.kt +57 -0
  13. package/android/src/main/java/com/darom/impl/DaroMBannerViewModuleImpl.kt +10 -0
  14. package/android/src/main/java/com/darom/impl/DaroMInterstitialModuleImpl.kt +113 -0
  15. package/android/src/main/java/com/darom/impl/DaroMLightPopupModuleImpl.kt +149 -0
  16. package/android/src/main/java/com/darom/impl/DaroMRewardedAdModuleImpl.kt +128 -0
  17. package/android/src/main/java/com/darom/util/AdInfoUtil.kt +51 -0
  18. package/android/src/main/java/com/darom/util/EventEmitterUtil.kt +24 -0
  19. package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +132 -0
  20. package/android/src/main/java/com/darom/view/DaroMAdNativeViewContainer.kt +372 -0
  21. package/android/src/main/res/layout/layout_activity_transparent.xml +7 -0
  22. package/android/src/main/res/values/styles.xml +11 -0
  23. package/ios/Daro+Extensions.swift +196 -0
  24. package/ios/DaroM-Bridging-Header.h +6 -0
  25. package/ios/DaroMAdBannerViewManager.m +15 -0
  26. package/ios/DaroMAdBannerViewManager.swift +87 -0
  27. package/ios/DaroMModule+AppOpen.swift +98 -0
  28. package/ios/DaroMModule+Interstitial.swift +100 -0
  29. package/ios/DaroMModule+LightPopup.swift +166 -0
  30. package/ios/DaroMModule+Rewarded.swift +118 -0
  31. package/ios/DaroMModule.mm +45 -0
  32. package/ios/DaroMModule.swift +218 -0
  33. package/ios/DaroMNativeAdViewManager.m +26 -0
  34. package/ios/DaroMNativeAdViewManager.swift +291 -0
  35. package/lib/commonjs/AdBannerView.js +115 -0
  36. package/lib/commonjs/AdBannerView.js.map +1 -0
  37. package/lib/commonjs/AppOpenAd.js +92 -0
  38. package/lib/commonjs/AppOpenAd.js.map +1 -0
  39. package/lib/commonjs/ErrorCode.js +11 -0
  40. package/lib/commonjs/ErrorCode.js.map +1 -0
  41. package/lib/commonjs/EventEmitter.js +30 -0
  42. package/lib/commonjs/EventEmitter.js.map +1 -0
  43. package/lib/commonjs/InterstitialAd.js +92 -0
  44. package/lib/commonjs/InterstitialAd.js.map +1 -0
  45. package/lib/commonjs/LightPopupAd.js +135 -0
  46. package/lib/commonjs/LightPopupAd.js.map +1 -0
  47. package/lib/commonjs/RewardedAd.js +105 -0
  48. package/lib/commonjs/RewardedAd.js.map +1 -0
  49. package/lib/commonjs/index.js +126 -0
  50. package/lib/commonjs/index.js.map +1 -0
  51. package/lib/commonjs/nativeAd/NativeAdView.js +103 -0
  52. package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -0
  53. package/lib/commonjs/nativeAd/NativeAdViewComponents.js +189 -0
  54. package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -0
  55. package/lib/commonjs/nativeAd/NativeAdViewProvider.js +29 -0
  56. package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -0
  57. package/lib/commonjs/types/AdBannerViewProps.js +6 -0
  58. package/lib/commonjs/types/AdBannerViewProps.js.map +1 -0
  59. package/lib/commonjs/types/AdEvent.js +6 -0
  60. package/lib/commonjs/types/AdEvent.js.map +1 -0
  61. package/lib/commonjs/types/AdInfo.js +6 -0
  62. package/lib/commonjs/types/AdInfo.js.map +1 -0
  63. package/lib/commonjs/types/AdProps.js +6 -0
  64. package/lib/commonjs/types/AdProps.js.map +1 -0
  65. package/lib/commonjs/types/AppOpenAd.js +6 -0
  66. package/lib/commonjs/types/AppOpenAd.js.map +1 -0
  67. package/lib/commonjs/types/DaroMMobileAds.js +2 -0
  68. package/lib/commonjs/types/DaroMMobileAds.js.map +1 -0
  69. package/lib/commonjs/types/FullScreenAd.js +6 -0
  70. package/lib/commonjs/types/FullScreenAd.js.map +1 -0
  71. package/lib/commonjs/types/InterstitialAd.js +6 -0
  72. package/lib/commonjs/types/InterstitialAd.js.map +1 -0
  73. package/lib/commonjs/types/LightPopupAd.js +6 -0
  74. package/lib/commonjs/types/LightPopupAd.js.map +1 -0
  75. package/lib/commonjs/types/NativeAdViewProps.js +6 -0
  76. package/lib/commonjs/types/NativeAdViewProps.js.map +1 -0
  77. package/lib/commonjs/types/RewardedAd.js +6 -0
  78. package/lib/commonjs/types/RewardedAd.js.map +1 -0
  79. package/lib/commonjs/types/index.js +61 -0
  80. package/lib/commonjs/types/index.js.map +1 -0
  81. package/lib/module/AdBannerView.js +111 -0
  82. package/lib/module/AdBannerView.js.map +1 -0
  83. package/lib/module/AppOpenAd.js +88 -0
  84. package/lib/module/AppOpenAd.js.map +1 -0
  85. package/lib/module/ErrorCode.js +7 -0
  86. package/lib/module/ErrorCode.js.map +1 -0
  87. package/lib/module/EventEmitter.js +24 -0
  88. package/lib/module/EventEmitter.js.map +1 -0
  89. package/lib/module/InterstitialAd.js +88 -0
  90. package/lib/module/InterstitialAd.js.map +1 -0
  91. package/lib/module/LightPopupAd.js +130 -0
  92. package/lib/module/LightPopupAd.js.map +1 -0
  93. package/lib/module/RewardedAd.js +101 -0
  94. package/lib/module/RewardedAd.js.map +1 -0
  95. package/lib/module/index.js +30 -0
  96. package/lib/module/index.js.map +1 -0
  97. package/lib/module/nativeAd/NativeAdView.js +99 -0
  98. package/lib/module/nativeAd/NativeAdView.js.map +1 -0
  99. package/lib/module/nativeAd/NativeAdViewComponents.js +179 -0
  100. package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -0
  101. package/lib/module/nativeAd/NativeAdViewProvider.js +23 -0
  102. package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -0
  103. package/lib/module/types/AdBannerViewProps.js +4 -0
  104. package/lib/module/types/AdBannerViewProps.js.map +1 -0
  105. package/lib/module/types/AdEvent.js +4 -0
  106. package/lib/module/types/AdEvent.js.map +1 -0
  107. package/lib/module/types/AdInfo.js +4 -0
  108. package/lib/module/types/AdInfo.js.map +1 -0
  109. package/lib/module/types/AdProps.js +4 -0
  110. package/lib/module/types/AdProps.js.map +1 -0
  111. package/lib/module/types/AppOpenAd.js +4 -0
  112. package/lib/module/types/AppOpenAd.js.map +1 -0
  113. package/lib/module/types/DaroMMobileAds.js +2 -0
  114. package/lib/module/types/DaroMMobileAds.js.map +1 -0
  115. package/lib/module/types/FullScreenAd.js +4 -0
  116. package/lib/module/types/FullScreenAd.js.map +1 -0
  117. package/lib/module/types/InterstitialAd.js +4 -0
  118. package/lib/module/types/InterstitialAd.js.map +1 -0
  119. package/lib/module/types/LightPopupAd.js +4 -0
  120. package/lib/module/types/LightPopupAd.js.map +1 -0
  121. package/lib/module/types/NativeAdViewProps.js +4 -0
  122. package/lib/module/types/NativeAdViewProps.js.map +1 -0
  123. package/lib/module/types/RewardedAd.js +4 -0
  124. package/lib/module/types/RewardedAd.js.map +1 -0
  125. package/lib/module/types/index.js +8 -0
  126. package/lib/module/types/index.js.map +1 -0
  127. package/lib/typescript/commonjs/package.json +1 -0
  128. package/lib/typescript/commonjs/src/AdBannerView.d.ts +12 -0
  129. package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -0
  130. package/lib/typescript/commonjs/src/AppOpenAd.d.ts +4 -0
  131. package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -0
  132. package/lib/typescript/commonjs/src/ErrorCode.d.ts +4 -0
  133. package/lib/typescript/commonjs/src/ErrorCode.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/src/EventEmitter.d.ts +4 -0
  135. package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/src/InterstitialAd.d.ts +4 -0
  137. package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/src/LightPopupAd.d.ts +4 -0
  139. package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/src/RewardedAd.d.ts +4 -0
  141. package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -0
  142. package/lib/typescript/commonjs/src/index.d.ts +11 -0
  143. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +6 -0
  145. package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts +7 -0
  147. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +14 -0
  149. package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +14 -0
  151. package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -0
  152. package/lib/typescript/commonjs/src/types/AdEvent.d.ts +7 -0
  153. package/lib/typescript/commonjs/src/types/AdEvent.d.ts.map +1 -0
  154. package/lib/typescript/commonjs/src/types/AdInfo.d.ts +19 -0
  155. package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/src/types/AdProps.d.ts +11 -0
  157. package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -0
  158. package/lib/typescript/commonjs/src/types/AppOpenAd.d.ts +3 -0
  159. package/lib/typescript/commonjs/src/types/AppOpenAd.d.ts.map +1 -0
  160. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts +6 -0
  161. package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/src/types/FullScreenAd.d.ts +21 -0
  163. package/lib/typescript/commonjs/src/types/FullScreenAd.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/src/types/InterstitialAd.d.ts +3 -0
  165. package/lib/typescript/commonjs/src/types/InterstitialAd.d.ts.map +1 -0
  166. package/lib/typescript/commonjs/src/types/LightPopupAd.d.ts +18 -0
  167. package/lib/typescript/commonjs/src/types/LightPopupAd.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +17 -0
  169. package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/src/types/RewardedAd.d.ts +9 -0
  171. package/lib/typescript/commonjs/src/types/RewardedAd.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/types/index.d.ts +6 -0
  173. package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -0
  174. package/lib/typescript/module/package.json +1 -0
  175. package/lib/typescript/module/src/AdBannerView.d.ts +12 -0
  176. package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -0
  177. package/lib/typescript/module/src/AppOpenAd.d.ts +4 -0
  178. package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -0
  179. package/lib/typescript/module/src/ErrorCode.d.ts +4 -0
  180. package/lib/typescript/module/src/ErrorCode.d.ts.map +1 -0
  181. package/lib/typescript/module/src/EventEmitter.d.ts +4 -0
  182. package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -0
  183. package/lib/typescript/module/src/InterstitialAd.d.ts +4 -0
  184. package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -0
  185. package/lib/typescript/module/src/LightPopupAd.d.ts +4 -0
  186. package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -0
  187. package/lib/typescript/module/src/RewardedAd.d.ts +4 -0
  188. package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -0
  189. package/lib/typescript/module/src/index.d.ts +11 -0
  190. package/lib/typescript/module/src/index.d.ts.map +1 -0
  191. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +6 -0
  192. package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -0
  193. package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts +7 -0
  194. package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -0
  195. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +14 -0
  196. package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -0
  197. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +14 -0
  198. package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -0
  199. package/lib/typescript/module/src/types/AdEvent.d.ts +7 -0
  200. package/lib/typescript/module/src/types/AdEvent.d.ts.map +1 -0
  201. package/lib/typescript/module/src/types/AdInfo.d.ts +19 -0
  202. package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -0
  203. package/lib/typescript/module/src/types/AdProps.d.ts +11 -0
  204. package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -0
  205. package/lib/typescript/module/src/types/AppOpenAd.d.ts +3 -0
  206. package/lib/typescript/module/src/types/AppOpenAd.d.ts.map +1 -0
  207. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts +6 -0
  208. package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +1 -0
  209. package/lib/typescript/module/src/types/FullScreenAd.d.ts +21 -0
  210. package/lib/typescript/module/src/types/FullScreenAd.d.ts.map +1 -0
  211. package/lib/typescript/module/src/types/InterstitialAd.d.ts +3 -0
  212. package/lib/typescript/module/src/types/InterstitialAd.d.ts.map +1 -0
  213. package/lib/typescript/module/src/types/LightPopupAd.d.ts +18 -0
  214. package/lib/typescript/module/src/types/LightPopupAd.d.ts.map +1 -0
  215. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +17 -0
  216. package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -0
  217. package/lib/typescript/module/src/types/RewardedAd.d.ts +9 -0
  218. package/lib/typescript/module/src/types/RewardedAd.d.ts.map +1 -0
  219. package/lib/typescript/module/src/types/index.d.ts +6 -0
  220. package/lib/typescript/module/src/types/index.d.ts.map +1 -0
  221. package/package.json +185 -0
  222. package/react-native-daro-m.podspec +44 -0
  223. package/src/AdBannerView.tsx +138 -0
  224. package/src/AppOpenAd.ts +113 -0
  225. package/src/ErrorCode.ts +4 -0
  226. package/src/EventEmitter.ts +25 -0
  227. package/src/InterstitialAd.ts +113 -0
  228. package/src/LightPopupAd.ts +161 -0
  229. package/src/RewardedAd.ts +130 -0
  230. package/src/index.tsx +37 -0
  231. package/src/nativeAd/NativeAdView.tsx +124 -0
  232. package/src/nativeAd/NativeAdViewComponents.tsx +239 -0
  233. package/src/nativeAd/NativeAdViewProvider.tsx +32 -0
  234. package/src/types/AdBannerViewProps.ts +15 -0
  235. package/src/types/AdEvent.ts +9 -0
  236. package/src/types/AdInfo.ts +37 -0
  237. package/src/types/AdProps.ts +18 -0
  238. package/src/types/AppOpenAd.ts +3 -0
  239. package/src/types/DaroMMobileAds.ts +8 -0
  240. package/src/types/FullScreenAd.ts +28 -0
  241. package/src/types/InterstitialAd.ts +3 -0
  242. package/src/types/LightPopupAd.ts +19 -0
  243. package/src/types/NativeAdViewProps.ts +18 -0
  244. package/src/types/RewardedAd.ts +15 -0
  245. package/src/types/index.ts +5 -0
@@ -0,0 +1,44 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-daro-m"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "15.1" }
15
+ s.source = { :git => "https://github.com/delightroom/daro-m-react-native.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+
19
+ s.dependency "DaroAds", "1.0.30-beta"
20
+
21
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
22
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
23
+ if respond_to?(:install_modules_dependencies, true)
24
+ install_modules_dependencies(s)
25
+ else
26
+ s.dependency "React-Core"
27
+
28
+ # Don't install the dependencies when we run `pod install` in the old architecture.
29
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
30
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
31
+ s.pod_target_xcconfig = {
32
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
33
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
34
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
35
+ }
36
+ s.dependency "React-RCTFabric"
37
+ s.dependency "React-Codegen"
38
+ s.dependency "RCT-Folly"
39
+ s.dependency "RCTRequired"
40
+ s.dependency "RCTTypeSafety"
41
+ s.dependency "ReactCommon/turbomodule/core"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,138 @@
1
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import { findNodeHandle, NativeModules, requireNativeComponent, UIManager, View, type DimensionValue, type NativeMethods, type ViewProps } from 'react-native';
3
+ import type { AdBannerViewHandler, AdBannerViewProps } from './types/AdBannerViewProps';
4
+ import type { AdNativeEvent } from './types/AdEvent';
5
+ import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
6
+
7
+ const { DaroMModule } = NativeModules;
8
+
9
+ const {
10
+ BANNER_AD_FORMAT_LABEL,
11
+ MREC_AD_FORMAT_LABEL,
12
+ } = DaroMModule.getConstants();
13
+
14
+ export enum AdFormat {
15
+ BANNER = BANNER_AD_FORMAT_LABEL,
16
+ MREC = MREC_AD_FORMAT_LABEL,
17
+ }
18
+
19
+ type AdViewNativeEvents = {
20
+ onAdLoadedEvent(event: AdNativeEvent<AdInfo>): void;
21
+ onAdLoadFailedEvent(event: AdNativeEvent<AdLoadFailedInfo>): void;
22
+ onAdClickedEvent(event: AdNativeEvent<AdInfo>): void;
23
+ onAdImpressionRecordedEvent(event: AdNativeEvent<AdInfo>): void;
24
+ };
25
+
26
+ const ComponentName = 'DaroMAdBannerView';
27
+ const AdViewComponent = requireNativeComponent<AdBannerViewProps & ViewProps & AdViewNativeEvents>(ComponentName);
28
+ type AdViewType = React.Component<AdBannerViewProps> & NativeMethods;
29
+
30
+ type SizeKey = 'width' | 'height';
31
+ type SizeRecord = Partial<Record<SizeKey, DimensionValue>>;
32
+
33
+ const ADVIEW_SIZE = {
34
+ banner: { width: 320, height: 50 },
35
+ mrec: { width: 300, height: 250 },
36
+ };
37
+
38
+ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps & ViewProps>(function AdBannerView(
39
+ {
40
+ adUnitId,
41
+ adFormat,
42
+ placement,
43
+ loadOnMount = true,
44
+ onAdLoaded,
45
+ onAdLoadFailed,
46
+ onAdClicked,
47
+ onAdImpressionRecorded,
48
+ style,
49
+ ...otherProps
50
+ },
51
+ ref
52
+ ) {
53
+
54
+ const adFormatSize = useRef<SizeRecord>({});
55
+ const adViewRef = useRef<AdViewType | null>(null);
56
+ const [isInitialized, setIsInitialized] = useState<boolean>(false);
57
+
58
+ const loadAd = useCallback(() => {
59
+ if (adViewRef.current) {
60
+ UIManager.dispatchViewManagerCommand(
61
+ findNodeHandle(adViewRef.current),
62
+ // @ts-ignore: Issue in RN ts defs
63
+ UIManager.getViewManagerConfig(ComponentName).Commands.loadAd,
64
+ [],
65
+ );
66
+ }
67
+ }, []);
68
+
69
+ useImperativeHandle(ref, () => ({ loadAd }), [loadAd]);
70
+
71
+ const saveElement = useCallback((element: AdViewType | null) => {
72
+ adViewRef.current = element;
73
+ }, []);
74
+
75
+ useEffect(() => {
76
+ (async () => {
77
+ if (adFormat === AdFormat.BANNER) {
78
+ adFormatSize.current = { width: ADVIEW_SIZE.banner.width, height: ADVIEW_SIZE.banner.height };
79
+ } else {
80
+ adFormatSize.current = { width: ADVIEW_SIZE.mrec.width, height: ADVIEW_SIZE.mrec.height };
81
+ }
82
+ const initialized = await DaroMModule.isInitialized();
83
+ setIsInitialized(initialized);
84
+
85
+ if (!initialized) {
86
+ console.warn('AdBannerView is mounted before the initialization of the DaroM React Native module');
87
+ }
88
+ })();
89
+ }, [adFormat]);
90
+
91
+ const onAdLoadedEvent = useCallback(
92
+ (event: AdNativeEvent<AdInfo>) => {
93
+ onAdLoaded?.(event.nativeEvent);
94
+ },
95
+ [onAdLoaded]
96
+ );
97
+
98
+ const onAdLoadFailedEvent = useCallback(
99
+ (event: AdNativeEvent<AdLoadFailedInfo>) => {
100
+ onAdLoadFailed?.(event.nativeEvent);
101
+ },
102
+ [onAdLoadFailed]
103
+ );
104
+
105
+ const onAdClickedEvent = useCallback(
106
+ (event: AdNativeEvent<AdInfo>) => {
107
+ onAdClicked?.(event.nativeEvent);
108
+ },
109
+ [onAdClicked]
110
+ );
111
+
112
+ const onAdImpressionRecordedEvent = useCallback(
113
+ (event: AdNativeEvent<AdInfo>) => {
114
+ onAdImpressionRecorded?.(event.nativeEvent);
115
+ },
116
+ [onAdImpressionRecorded]
117
+ );
118
+
119
+ if (!isInitialized) {
120
+ // Early return if not initialized
121
+ console.log('AdBannerView is not initialized');
122
+ return <View style={style} {...otherProps} />;
123
+ }
124
+
125
+ return (
126
+ <AdViewComponent
127
+ style={style}
128
+ adFormat={adFormat}
129
+ ref={saveElement}
130
+ adUnitId={adUnitId}
131
+ placement={placement}
132
+ onAdLoadedEvent={onAdLoadedEvent}
133
+ onAdLoadFailedEvent={onAdLoadFailedEvent}
134
+ onAdClickedEvent={onAdClickedEvent}
135
+ onAdImpressionRecordedEvent={onAdImpressionRecordedEvent}
136
+ {...otherProps} />
137
+ );
138
+ });
@@ -0,0 +1,113 @@
1
+ import { NativeModules } from 'react-native';
2
+ import { addEventListener, removeEventListener } from './EventEmitter';
3
+ import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo } from './types/AdInfo';
4
+ import type { AppOpenAdType } from './types/AppOpenAd';
5
+
6
+ const { DaroMModule } = NativeModules;
7
+
8
+ const {
9
+ ON_APPOPEN_AD_LOADED_EVENT,
10
+ ON_APPOPEN_AD_LOAD_FAILED_EVENT,
11
+ ON_APPOPEN_AD_CLICKED_EVENT,
12
+ ON_APPOPEN_AD_DISPLAYED_EVENT,
13
+ ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
14
+ ON_APPOPEN_AD_HIDDEN_EVENT,
15
+ ON_APPOPEN_AD_IMPRESSION_RECORDED,
16
+ } = DaroMModule.getConstants();
17
+
18
+ const isAdReady = (adUnitId: string): Promise<boolean> => {
19
+ return DaroMModule.isAppOpenAdReady(adUnitId);
20
+ };
21
+
22
+ const loadAd = (adUnitId: string): void => {
23
+ DaroMModule.loadAppOpenAd(adUnitId);
24
+ };
25
+
26
+ const showAd = (adUnitId: string, placement?: string | null, customData?: string | null): void => {
27
+ DaroMModule.showAppOpenAd(adUnitId, placement ?? undefined, customData ?? undefined);
28
+ };
29
+
30
+ const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void): void => {
31
+ addEventListener(ON_APPOPEN_AD_LOADED_EVENT, listener);
32
+ };
33
+
34
+ const removeAdLoadedEventListener = (): void => {
35
+ removeEventListener(ON_APPOPEN_AD_LOADED_EVENT);
36
+ };
37
+
38
+ const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void): void => {
39
+ addEventListener(ON_APPOPEN_AD_LOAD_FAILED_EVENT, listener);
40
+ };
41
+
42
+ const removeAdLoadFailedEventListener = (): void => {
43
+ removeEventListener(ON_APPOPEN_AD_LOAD_FAILED_EVENT);
44
+ };
45
+
46
+ const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void): void => {
47
+ addEventListener(ON_APPOPEN_AD_CLICKED_EVENT, listener);
48
+ };
49
+
50
+ const removeAdClickedEventListener = (): void => {
51
+ removeEventListener(ON_APPOPEN_AD_CLICKED_EVENT);
52
+ };
53
+
54
+ const addAdDisplayedEventListener = (listener: (adInfo: AdInfo) => void): void => {
55
+ addEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT, listener);
56
+ };
57
+
58
+ const removeAdDisplayedEventListener = (): void => {
59
+ removeEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT);
60
+ };
61
+
62
+ const addAdFailedToDisplayEventListener = (listener: (errorInfo: AdDisplayFailedInfo) => void): void => {
63
+ addEventListener(ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT, listener);
64
+ };
65
+
66
+ const removeAdFailedToDisplayEventListener = (): void => {
67
+ removeEventListener(ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT);
68
+ };
69
+
70
+ const addAdHiddenEventListener = (listener: (adInfo: AdInfo) => void): void => {
71
+ addEventListener(ON_APPOPEN_AD_HIDDEN_EVENT, listener);
72
+ };
73
+
74
+ const removeAdHiddenEventListener = (): void => {
75
+ removeEventListener(ON_APPOPEN_AD_HIDDEN_EVENT);
76
+ };
77
+
78
+ const addAdImpressionRecordedListener = (listener: (adInfo: AdInfo) => void): void => {
79
+ addEventListener(ON_APPOPEN_AD_IMPRESSION_RECORDED, listener);
80
+ };
81
+
82
+ const removeAdImpressionRecordedListener = (): void => {
83
+ removeEventListener(ON_APPOPEN_AD_IMPRESSION_RECORDED);
84
+ };
85
+
86
+ export const AppOpenAd: AppOpenAdType = {
87
+ isAdReady,
88
+ loadAd,
89
+ showAd,
90
+
91
+ addAdLoadedEventListener,
92
+ removeAdLoadedEventListener,
93
+
94
+ addAdLoadFailedEventListener,
95
+ removeAdLoadFailedEventListener,
96
+
97
+ addAdClickedEventListener,
98
+ removeAdClickedEventListener,
99
+
100
+ addAdDisplayedEventListener,
101
+ removeAdDisplayedEventListener,
102
+
103
+ addAdFailedToDisplayEventListener,
104
+ removeAdFailedToDisplayEventListener,
105
+
106
+ addAdHiddenEventListener,
107
+ removeAdHiddenEventListener,
108
+
109
+ addAdImpressionRecordedListener,
110
+ removeAdImpressionRecordedListener,
111
+ };
112
+
113
+ export default AppOpenAd;
@@ -0,0 +1,4 @@
1
+
2
+ export enum ErrorCode {
3
+ UNSPECIFIED = 0
4
+ }
@@ -0,0 +1,25 @@
1
+ import { NativeModules, NativeEventEmitter } from 'react-native';
2
+ import type { EventSubscription } from 'react-native';
3
+ import type { AdEventObject, AdEventListener } from './types/AdEvent';
4
+
5
+ const { DaroMModule } = NativeModules;
6
+
7
+ const emitter = new NativeEventEmitter(DaroMModule);
8
+ const subscriptions: Record<string, EventSubscription> = {};
9
+
10
+ export const addEventListener = <T extends AdEventObject>(event: string, handler: AdEventListener<T>): void => {
11
+ const subscription: EventSubscription = emitter.addListener(event, handler);
12
+ const currentSubscription = subscriptions[event];
13
+ if (currentSubscription) {
14
+ currentSubscription.remove();
15
+ }
16
+ subscriptions[event] = subscription;
17
+ };
18
+
19
+ export const removeEventListener = (event: string): void => {
20
+ const currentSubscription = subscriptions[event];
21
+ if (currentSubscription) {
22
+ currentSubscription.remove();
23
+ delete subscriptions[event];
24
+ }
25
+ };
@@ -0,0 +1,113 @@
1
+ import { NativeModules } from "react-native";
2
+ import { addEventListener, removeEventListener } from "./EventEmitter";
3
+ import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo } from "./types/AdInfo";
4
+ import type { InterstitialAdType } from "./types/InterstitialAd";
5
+
6
+ const { DaroMModule } = NativeModules;
7
+
8
+ const {
9
+ ON_INTERSTITIAL_LOADED_EVENT,
10
+ ON_INTERSTITIAL_LOAD_FAILED_EVENT,
11
+ ON_INTERSTITIAL_CLICKED_EVENT,
12
+ ON_INTERSTITIAL_DISPLAYED_EVENT,
13
+ ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT,
14
+ ON_INTERSTITIAL_HIDDEN_EVENT,
15
+ ON_INTERSTITIAL_AD_IMPRESSION_RECORDED,
16
+ } = DaroMModule.getConstants();
17
+
18
+ const isAdReady = (adUnitId: string): Promise<boolean> => {
19
+ return DaroMModule.isInterstitialReady(adUnitId);
20
+ };
21
+
22
+ const loadAd = (adUnitId: string): void => {
23
+ DaroMModule.loadInterstitial(adUnitId);
24
+ };
25
+
26
+ const showAd = (adUnitId: string): void => {
27
+ DaroMModule.showInterstitial(adUnitId);
28
+ };
29
+
30
+ const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void): void => {
31
+ addEventListener(ON_INTERSTITIAL_LOADED_EVENT, listener);
32
+ };
33
+
34
+ const removeAdLoadedEventListener = (): void => {
35
+ removeEventListener(ON_INTERSTITIAL_LOADED_EVENT);
36
+ };
37
+
38
+ const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void): void => {
39
+ addEventListener(ON_INTERSTITIAL_LOAD_FAILED_EVENT, listener);
40
+ };
41
+
42
+ const removeAdLoadFailedEventListener = (): void => {
43
+ removeEventListener(ON_INTERSTITIAL_LOAD_FAILED_EVENT);
44
+ };
45
+
46
+ const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void): void => {
47
+ addEventListener(ON_INTERSTITIAL_CLICKED_EVENT, listener);
48
+ };
49
+
50
+ const removeAdClickedEventListener = (): void => {
51
+ removeEventListener(ON_INTERSTITIAL_CLICKED_EVENT);
52
+ };
53
+
54
+ const addAdDisplayedEventListener = (listener: (adInfo: AdInfo) => void): void => {
55
+ addEventListener(ON_INTERSTITIAL_DISPLAYED_EVENT, listener);
56
+ };
57
+
58
+ const removeAdDisplayedEventListener = (): void => {
59
+ removeEventListener(ON_INTERSTITIAL_DISPLAYED_EVENT);
60
+ };
61
+
62
+ const addAdFailedToDisplayEventListener = (listener: (errorInfo: AdDisplayFailedInfo) => void): void => {
63
+ addEventListener(ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT, listener);
64
+ };
65
+
66
+ const removeAdFailedToDisplayEventListener = (): void => {
67
+ removeEventListener(ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT);
68
+ };
69
+
70
+ const addAdHiddenEventListener = (listener: (adInfo: AdInfo) => void): void => {
71
+ addEventListener(ON_INTERSTITIAL_HIDDEN_EVENT, listener);
72
+ };
73
+
74
+ const removeAdHiddenEventListener = (): void => {
75
+ removeEventListener(ON_INTERSTITIAL_HIDDEN_EVENT);
76
+ };
77
+
78
+ const addAdImpressionRecordedListener = (listener: (adInfo: AdInfo) => void): void => {
79
+ addEventListener(ON_INTERSTITIAL_AD_IMPRESSION_RECORDED, listener);
80
+ };
81
+
82
+ const removeAdImpressionRecordedListener = (): void => {
83
+ removeEventListener(ON_INTERSTITIAL_AD_IMPRESSION_RECORDED);
84
+ };
85
+
86
+ export const InterstitialAd: InterstitialAdType = {
87
+ isAdReady,
88
+ loadAd,
89
+ showAd,
90
+
91
+ addAdLoadedEventListener,
92
+ removeAdLoadedEventListener,
93
+
94
+ addAdLoadFailedEventListener,
95
+ removeAdLoadFailedEventListener,
96
+
97
+ addAdClickedEventListener,
98
+ removeAdClickedEventListener,
99
+
100
+ addAdDisplayedEventListener,
101
+ removeAdDisplayedEventListener,
102
+
103
+ addAdFailedToDisplayEventListener,
104
+ removeAdFailedToDisplayEventListener,
105
+
106
+ addAdHiddenEventListener,
107
+ removeAdHiddenEventListener,
108
+
109
+ addAdImpressionRecordedListener,
110
+ removeAdImpressionRecordedListener,
111
+ }
112
+
113
+ export default InterstitialAd;
@@ -0,0 +1,161 @@
1
+ import { NativeModules } from "react-native";
2
+ import { addEventListener, removeEventListener } from "./EventEmitter";
3
+ import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo } from "./types/AdInfo";
4
+ import type { LightPopupAdConfiguration, LightPopupAdType } from "./types/LightPopupAd";
5
+ import tinycolor from "tinycolor2";
6
+
7
+ const { DaroMModule } = NativeModules;
8
+
9
+ const {
10
+ ON_LIGHTPOPUP_LOADED_EVENT,
11
+ ON_LIGHTPOPUP_LOAD_FAILED_EVENT,
12
+ ON_LIGHTPOPUP_CLICKED_EVENT,
13
+ ON_LIGHTPOPUP_DISPLAYED_EVENT,
14
+ ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT,
15
+ ON_LIGHTPOPUP_HIDDEN_EVENT,
16
+ ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED,
17
+ } = DaroMModule.getConstants();
18
+
19
+ const isAdReady = (adUnitId: string): Promise<boolean> => {
20
+ return DaroMModule.isLightPopupReady(adUnitId);
21
+ };
22
+
23
+ const loadAd = (adUnitId: string): void => {
24
+ DaroMModule.loadLightPopup(adUnitId);
25
+ };
26
+
27
+ const showAd = (adUnitId: string): void => {
28
+ DaroMModule.showLightPopup(adUnitId);
29
+ };
30
+
31
+ function colorToHex(color: any): string | undefined {
32
+ if (typeof color === "number") {
33
+ // react-native에서 number로 오는 경우 (ex: processColor)
34
+ // #AARRGGBB로 변환
35
+ return `#${color.toString(16).padStart(8, "0")}`.toUpperCase();
36
+ }
37
+ if (typeof color === "string") {
38
+ const tc = tinycolor(color);
39
+ if (tc.isValid()) {
40
+ // alpha가 1이면 #RRGGBB, 아니면 #AARRGGBB
41
+ const hex = tc.toHexString().toUpperCase();
42
+ const alpha = Math.round(tc.getAlpha() * 255);
43
+ if (alpha === 255) {
44
+ return hex;
45
+ } else {
46
+ // #AARRGGBB
47
+ return (
48
+ "#" +
49
+ alpha.toString(16).padStart(2, "0").toUpperCase() +
50
+ tc.toHex().toUpperCase()
51
+ );
52
+ }
53
+ }
54
+ }
55
+ return undefined;
56
+ }
57
+
58
+ const setLightPopupAdConfiguration = (adUnitId: string, configuration: LightPopupAdConfiguration): void => {
59
+ const config = { ...configuration };
60
+
61
+ // color 관련 필드만 hex string으로 변환
62
+ if (config.backgroundColor) config.backgroundColor = colorToHex(config.backgroundColor);
63
+ if (config.cardViewBackgroundColor) config.cardViewBackgroundColor = colorToHex(config.cardViewBackgroundColor);
64
+ if (config.adMarkLabelTextColor) config.adMarkLabelTextColor = colorToHex(config.adMarkLabelTextColor);
65
+ if (config.adMarkLabelBackgroundColor) config.adMarkLabelBackgroundColor = colorToHex(config.adMarkLabelBackgroundColor);
66
+ if (config.closeButtonText) config.closeButtonText = config.closeButtonText;
67
+ if (config.closeButtonTextColor) config.closeButtonTextColor = colorToHex(config.closeButtonTextColor);
68
+ if (config.titleTextColor) config.titleTextColor = colorToHex(config.titleTextColor);
69
+ if (config.bodyTextColor) config.bodyTextColor = colorToHex(config.bodyTextColor);
70
+ if (config.ctaButtonTextColor) config.ctaButtonTextColor = colorToHex(config.ctaButtonTextColor);
71
+ if (config.ctaButtonBackgroundColor) config.ctaButtonBackgroundColor = colorToHex(config.ctaButtonBackgroundColor);
72
+
73
+ DaroMModule.setLightPopupAdConfiguration(adUnitId, config);
74
+ };
75
+
76
+ const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void): void => {
77
+ addEventListener(ON_LIGHTPOPUP_LOADED_EVENT, listener);
78
+ };
79
+
80
+ const removeAdLoadedEventListener = (): void => {
81
+ removeEventListener(ON_LIGHTPOPUP_LOADED_EVENT);
82
+ };
83
+
84
+ const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void): void => {
85
+ addEventListener(ON_LIGHTPOPUP_LOAD_FAILED_EVENT, listener);
86
+ };
87
+
88
+ const removeAdLoadFailedEventListener = (): void => {
89
+ removeEventListener(ON_LIGHTPOPUP_LOAD_FAILED_EVENT);
90
+ };
91
+
92
+ const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void): void => {
93
+ addEventListener(ON_LIGHTPOPUP_CLICKED_EVENT, listener);
94
+ };
95
+
96
+ const removeAdClickedEventListener = (): void => {
97
+ removeEventListener(ON_LIGHTPOPUP_CLICKED_EVENT);
98
+ };
99
+
100
+ const addAdDisplayedEventListener = (listener: (adInfo: AdInfo) => void): void => {
101
+ addEventListener(ON_LIGHTPOPUP_DISPLAYED_EVENT, listener);
102
+ };
103
+
104
+ const removeAdDisplayedEventListener = (): void => {
105
+ removeEventListener(ON_LIGHTPOPUP_DISPLAYED_EVENT);
106
+ };
107
+
108
+ const addAdFailedToDisplayEventListener = (listener: (errorInfo: AdDisplayFailedInfo) => void): void => {
109
+ addEventListener(ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT, listener);
110
+ };
111
+
112
+ const removeAdFailedToDisplayEventListener = (): void => {
113
+ removeEventListener(ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT);
114
+ };
115
+
116
+ const addAdHiddenEventListener = (listener: (adInfo: AdInfo) => void): void => {
117
+ addEventListener(ON_LIGHTPOPUP_HIDDEN_EVENT, listener);
118
+ };
119
+
120
+ const removeAdHiddenEventListener = (): void => {
121
+ removeEventListener(ON_LIGHTPOPUP_HIDDEN_EVENT);
122
+ };
123
+
124
+ const addAdImpressionRecordedListener = (listener: (adInfo: AdInfo) => void): void => {
125
+ addEventListener(ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED, listener);
126
+ };
127
+
128
+ const removeAdImpressionRecordedListener = (): void => {
129
+ removeEventListener(ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED);
130
+ };
131
+
132
+ export const LightPopupAd: LightPopupAdType = {
133
+ isAdReady,
134
+ loadAd,
135
+ showAd,
136
+
137
+ addAdLoadedEventListener,
138
+ removeAdLoadedEventListener,
139
+
140
+ addAdLoadFailedEventListener,
141
+ removeAdLoadFailedEventListener,
142
+
143
+ addAdClickedEventListener,
144
+ removeAdClickedEventListener,
145
+
146
+ addAdDisplayedEventListener,
147
+ removeAdDisplayedEventListener,
148
+
149
+ addAdFailedToDisplayEventListener,
150
+ removeAdFailedToDisplayEventListener,
151
+
152
+ addAdHiddenEventListener,
153
+ removeAdHiddenEventListener,
154
+
155
+ addAdImpressionRecordedListener,
156
+ removeAdImpressionRecordedListener,
157
+
158
+ setLightPopupAdConfiguration,
159
+ };
160
+
161
+ export default LightPopupAd;