react-native-daro 1.0.13 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +30 -30
- package/android/build.gradle +52 -59
- package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +23 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/{darom → daro/reactnative}/DaroMAdBannerViewManager.kt +38 -15
- package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +167 -0
- package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +257 -0
- package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +45 -0
- package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
- package/android/src/main/java/com/{darom → daro/reactnative}/constants/InternalDaroMBannerSize.kt +1 -1
- package/android/src/main/java/com/{darom → daro/reactnative}/event/DaroMEvent.kt +19 -8
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMBannerViewModuleImpl.kt +2 -2
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMInterstitialModuleImpl.kt +26 -26
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMLightPopupModuleImpl.kt +30 -29
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMRewardedAdModuleImpl.kt +27 -27
- package/android/src/main/java/com/{darom → daro/reactnative}/util/AdInfoUtil.kt +25 -1
- package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +37 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdBannerViewContainer.kt +417 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +624 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +123 -0
- package/android/src/newarch/java/com/daro/reactnative/DaroMModuleSpec.kt +6 -0
- package/android/src/oldarch/java/com/daro/reactnative/DaroMModuleSpec.kt +90 -0
- package/app.plugin.js +1 -0
- package/ios/DaroMModule+AppOpen.swift +38 -32
- package/ios/DaroMModule+Interstitial.swift +32 -26
- package/ios/DaroMModule+LightPopup.swift +43 -33
- package/ios/DaroMModule+Rewarded.swift +38 -27
- package/ios/DaroMModule.mm +45 -17
- package/ios/DaroMModule.swift +24 -17
- package/ios/Fabric/DaroMAdBannerComponentView.mm +207 -0
- package/ios/Fabric/DaroMFabricEventSink.mm +31 -0
- package/ios/Fabric/DaroMFabricPropApplier.mm +123 -0
- package/ios/Fabric/DaroMNativeAdComponentView.mm +294 -0
- package/ios/{DaroMAdBannerViewManager.m → Paper/DaroMAdBannerViewManager.m} +3 -1
- package/ios/Paper/DaroMAdBannerViewManager.swift +21 -0
- package/ios/{DaroMNativeAdViewManager.m → Paper/DaroMNativeAdViewManager.m} +2 -1
- package/ios/Paper/DaroMNativeAdViewManager.swift +22 -0
- package/ios/Shared/DaroMAdEventSink.swift +24 -0
- package/ios/Shared/DaroMBannerAdView.swift +188 -0
- package/ios/Shared/DaroMNativeAdLoadCoordinator.swift +49 -0
- package/ios/Shared/DaroMNativeAdView.swift +575 -0
- package/ios/Shared/DaroMNativeAssetResolver.swift +53 -0
- package/ios/mediation/admob/DaroMediationDebugger.swift +11 -0
- package/ios/mediation/admob/DaroMediationTypes.swift +23 -0
- package/lib/commonjs/AdBannerView.js +21 -35
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +80 -21
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/lib/commonjs/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/lib/commonjs/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/commonjs/ErrorCode.js.map +1 -1
- package/lib/commonjs/EventEmitter.js +4 -5
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/InterstitialAd.js +48 -22
- package/lib/commonjs/InterstitialAd.js.map +1 -1
- package/lib/commonjs/LightPopupAd.js +64 -46
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/NativeDaroModule.js +9 -0
- package/lib/commonjs/NativeDaroModule.js.map +1 -0
- package/lib/commonjs/RewardedAd.js +47 -23
- package/lib/commonjs/RewardedAd.js.map +1 -1
- package/lib/commonjs/codegen-env.d.js +2 -0
- package/lib/commonjs/codegen-env.d.js.map +1 -0
- package/lib/commonjs/hooks/useInterstitialAd.js +110 -0
- package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
- package/lib/commonjs/hooks/useLightPopupAd.js +114 -0
- package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -0
- package/lib/commonjs/hooks/useRewardedAd.js +113 -0
- package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
- package/lib/commonjs/index.js +29 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +23 -18
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js +43 -31
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js +34 -7
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/module/AdBannerView.js +20 -36
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +80 -22
- package/lib/module/AppOpenAd.js.map +1 -1
- package/lib/module/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/lib/module/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/lib/module/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/module/ErrorCode.js.map +1 -1
- package/lib/module/EventEmitter.js +4 -6
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/InterstitialAd.js +47 -22
- package/lib/module/InterstitialAd.js.map +1 -1
- package/lib/module/LightPopupAd.js +65 -47
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/NativeDaroModule.js +5 -0
- package/lib/module/NativeDaroModule.js.map +1 -0
- package/lib/module/RewardedAd.js +46 -23
- package/lib/module/RewardedAd.js.map +1 -1
- package/lib/module/codegen-env.d.js +2 -0
- package/lib/module/codegen-env.d.js.map +1 -0
- package/lib/module/hooks/useInterstitialAd.js +106 -0
- package/lib/module/hooks/useInterstitialAd.js.map +1 -0
- package/lib/module/hooks/useLightPopupAd.js +110 -0
- package/lib/module/hooks/useLightPopupAd.js.map +1 -0
- package/lib/module/hooks/useRewardedAd.js +109 -0
- package/lib/module/hooks/useRewardedAd.js.map +1 -0
- package/lib/module/index.js +7 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +22 -19
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewComponents.js +45 -34
- package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewProvider.js +35 -8
- package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/plugin/src/index.d.ts +19 -0
- package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts +6 -0
- package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +8 -0
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts +8 -0
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/AdBannerView.d.ts +126 -4
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ErrorCode.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +61 -0
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/RewardedAd.d.ts +6 -0
- package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +19 -0
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +23 -0
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +20 -0
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +7 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +125 -2
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +2 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/index.d.ts +19 -0
- package/lib/typescript/module/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts +6 -0
- package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/withAndroid.d.ts +8 -0
- package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/withIos.d.ts +8 -0
- package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -0
- package/lib/typescript/module/src/AdBannerView.d.ts +126 -4
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/module/src/AppOpenAd.d.ts +6 -0
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/ErrorCode.d.ts.map +1 -1
- package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/module/src/InterstitialAd.d.ts +6 -0
- package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/module/src/LightPopupAd.d.ts +6 -0
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeDaroModule.d.ts +61 -0
- package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -0
- package/lib/typescript/module/src/RewardedAd.d.ts +6 -0
- package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +19 -0
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +23 -0
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +20 -0
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +7 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +125 -2
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +2 -2
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdProps.d.ts +2 -2
- package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +1 -1
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +2 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +95 -105
- package/plugin/build/index.d.ts +18 -0
- package/plugin/build/index.js +71 -0
- package/plugin/build/skAdNetworkIds.d.ts +5 -0
- package/plugin/build/skAdNetworkIds.js +205 -0
- package/plugin/build/withAndroid.d.ts +7 -0
- package/plugin/build/withAndroid.js +222 -0
- package/plugin/build/withIos.d.ts +7 -0
- package/plugin/build/withIos.js +82 -0
- package/react-native-daro.podspec +28 -0
- package/src/AdBannerView.tsx +48 -48
- package/src/AppOpenAd.ts +101 -20
- package/src/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/src/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/src/DaroMediaViewNativeComponent.ts +9 -0
- package/src/ErrorCode.ts +1 -2
- package/src/EventEmitter.ts +9 -7
- package/src/InterstitialAd.ts +75 -21
- package/src/LightPopupAd.ts +90 -51
- package/src/NativeDaroModule.ts +91 -0
- package/src/RewardedAd.ts +72 -22
- package/src/codegen-env.d.ts +45 -0
- package/src/hooks/useInterstitialAd.ts +117 -0
- package/src/hooks/useLightPopupAd.ts +132 -0
- package/src/hooks/useRewardedAd.ts +122 -0
- package/src/index.tsx +21 -22
- package/src/nativeAd/NativeAdView.tsx +83 -45
- package/src/nativeAd/NativeAdViewComponents.tsx +129 -64
- package/src/nativeAd/NativeAdViewProvider.tsx +84 -16
- package/src/types/AdBannerViewProps.ts +11 -11
- package/src/types/AdInfo.ts +17 -17
- package/src/types/AdProps.ts +8 -9
- package/src/types/DaroMMobileAds.ts +3 -6
- package/src/types/NativeAdViewProps.ts +12 -5
- package/src/types/index.ts +1 -1
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifestNew.xml +0 -7
- package/android/src/main/java/com/darom/DaroMAdNativeViewManager.kt +0 -136
- package/android/src/main/java/com/darom/DaroMModule.kt +0 -203
- package/android/src/main/java/com/darom/DaroMPackage.kt +0 -21
- package/android/src/main/java/com/darom/util/EventEmitterUtil.kt +0 -24
- package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +0 -163
- package/android/src/main/java/com/darom/view/DaroMAdNativeViewContainer.kt +0 -375
- package/android/src/main/res/layout/layout_activity_transparent.xml +0 -7
- package/android/src/main/res/values/styles.xml +0 -11
- package/ios/DaroM-Bridging-Header.h +0 -6
- package/ios/DaroMAdBannerViewManager.swift +0 -91
- package/ios/DaroMNativeAdViewManager.swift +0 -291
- package/react-native-daro-m.podspec +0 -44
package/src/AdBannerView.tsx
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type ElementRef,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import { View, type ViewProps } from 'react-native';
|
|
11
|
+
import AdBannerViewNativeComponent, {
|
|
12
|
+
Commands,
|
|
13
|
+
} from './DaroMAdBannerViewNativeComponent';
|
|
14
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
15
|
+
import type {
|
|
16
|
+
AdBannerViewHandler,
|
|
17
|
+
AdBannerViewProps,
|
|
18
|
+
} from './types/AdBannerViewProps';
|
|
4
19
|
import type { AdNativeEvent } from './types/AdEvent';
|
|
5
20
|
import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
|
|
6
21
|
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
BANNER_AD_FORMAT_LABEL,
|
|
11
|
-
MREC_AD_FORMAT_LABEL,
|
|
12
|
-
} = DaroMModule.getConstants();
|
|
22
|
+
const { BANNER_AD_FORMAT_LABEL, MREC_AD_FORMAT_LABEL } =
|
|
23
|
+
NativeDaroModule.getConstants();
|
|
13
24
|
|
|
14
25
|
export enum AdFormat {
|
|
15
|
-
BANNER =
|
|
16
|
-
MREC =
|
|
26
|
+
BANNER = 'BANNER',
|
|
27
|
+
MREC = 'MREC',
|
|
17
28
|
}
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
const toNativeAdFormat = (adFormat: AdFormat | string): string => {
|
|
31
|
+
switch (adFormat) {
|
|
32
|
+
case AdFormat.BANNER:
|
|
33
|
+
return BANNER_AD_FORMAT_LABEL;
|
|
34
|
+
case AdFormat.MREC:
|
|
35
|
+
return MREC_AD_FORMAT_LABEL;
|
|
36
|
+
default:
|
|
37
|
+
return adFormat;
|
|
38
|
+
}
|
|
24
39
|
};
|
|
25
40
|
|
|
26
|
-
|
|
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
|
-
};
|
|
41
|
+
type AdViewType = ElementRef<typeof AdBannerViewNativeComponent>;
|
|
37
42
|
|
|
38
|
-
export const AdBannerView = forwardRef<
|
|
43
|
+
export const AdBannerView = forwardRef<
|
|
44
|
+
AdBannerViewHandler,
|
|
45
|
+
AdBannerViewProps & ViewProps
|
|
46
|
+
>(function AdBannerView(
|
|
39
47
|
{
|
|
40
48
|
adUnitId,
|
|
41
49
|
adFormat,
|
|
@@ -51,19 +59,12 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
|
|
|
51
59
|
},
|
|
52
60
|
ref
|
|
53
61
|
) {
|
|
54
|
-
|
|
55
|
-
const adFormatSize = useRef<SizeRecord>({});
|
|
56
62
|
const adViewRef = useRef<AdViewType | null>(null);
|
|
57
63
|
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
58
64
|
|
|
59
65
|
const loadAd = useCallback(() => {
|
|
60
66
|
if (adViewRef.current) {
|
|
61
|
-
|
|
62
|
-
findNodeHandle(adViewRef.current),
|
|
63
|
-
// @ts-ignore: Issue in RN ts defs
|
|
64
|
-
UIManager.getViewManagerConfig(ComponentName).Commands.loadAd,
|
|
65
|
-
[],
|
|
66
|
-
);
|
|
67
|
+
Commands.loadAd(adViewRef.current);
|
|
67
68
|
}
|
|
68
69
|
}, []);
|
|
69
70
|
|
|
@@ -75,19 +76,16 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
|
|
|
75
76
|
|
|
76
77
|
useEffect(() => {
|
|
77
78
|
(async () => {
|
|
78
|
-
|
|
79
|
-
adFormatSize.current = { width: ADVIEW_SIZE.banner.width, height: ADVIEW_SIZE.banner.height };
|
|
80
|
-
} else {
|
|
81
|
-
adFormatSize.current = { width: ADVIEW_SIZE.mrec.width, height: ADVIEW_SIZE.mrec.height };
|
|
82
|
-
}
|
|
83
|
-
const initialized = await DaroMModule.isInitialized();
|
|
79
|
+
const initialized = await NativeDaroModule.isInitialized();
|
|
84
80
|
setIsInitialized(initialized);
|
|
85
81
|
|
|
86
82
|
if (!initialized) {
|
|
87
|
-
console.warn(
|
|
83
|
+
console.warn(
|
|
84
|
+
'AdBannerView is mounted before the initialization of the DaroM React Native module'
|
|
85
|
+
);
|
|
88
86
|
}
|
|
89
87
|
})();
|
|
90
|
-
}, [
|
|
88
|
+
}, []);
|
|
91
89
|
|
|
92
90
|
const onAdLoadedEvent = useCallback(
|
|
93
91
|
(event: AdNativeEvent<AdInfo>) => {
|
|
@@ -124,17 +122,19 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
|
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
return (
|
|
127
|
-
<
|
|
125
|
+
<AdBannerViewNativeComponent
|
|
128
126
|
style={style}
|
|
129
|
-
adFormat={adFormat}
|
|
127
|
+
adFormat={toNativeAdFormat(adFormat)}
|
|
130
128
|
ref={saveElement}
|
|
131
129
|
adUnitId={adUnitId}
|
|
132
130
|
placement={placement}
|
|
131
|
+
loadOnMount={loadOnMount}
|
|
133
132
|
isVisible={isVisible}
|
|
134
133
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
135
134
|
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
136
135
|
onAdClickedEvent={onAdClickedEvent}
|
|
137
136
|
onAdImpressionRecordedEvent={onAdImpressionRecordedEvent}
|
|
138
|
-
{...otherProps}
|
|
137
|
+
{...otherProps}
|
|
138
|
+
/>
|
|
139
139
|
);
|
|
140
|
-
});
|
|
140
|
+
});
|
package/src/AppOpenAd.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
2
|
import {
|
|
3
3
|
addEventListener,
|
|
4
4
|
removeEventListener,
|
|
5
5
|
AdEventEmitter,
|
|
6
6
|
} from './EventEmitter';
|
|
7
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
7
8
|
import type {
|
|
8
9
|
AdDisplayFailedInfo,
|
|
9
10
|
AdInfo,
|
|
@@ -11,7 +12,11 @@ import type {
|
|
|
11
12
|
} from './types/AdInfo';
|
|
12
13
|
import { AdEventType, type AdEventPayloadMap } from './types/AdEvent';
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
+
const IS_SUPPORTED_PLATFORM = Platform.OS === 'ios';
|
|
16
|
+
|
|
17
|
+
const warnUnsupportedPlatform = () => {
|
|
18
|
+
console.warn('AppOpenAd is only supported on iOS.');
|
|
19
|
+
};
|
|
15
20
|
|
|
16
21
|
const {
|
|
17
22
|
ON_APPOPEN_AD_LOADED_EVENT,
|
|
@@ -21,7 +26,7 @@ const {
|
|
|
21
26
|
ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
|
|
22
27
|
ON_APPOPEN_AD_HIDDEN_EVENT,
|
|
23
28
|
ON_APPOPEN_AD_IMPRESSION_RECORDED,
|
|
24
|
-
} =
|
|
29
|
+
} = NativeDaroModule.getConstants();
|
|
25
30
|
|
|
26
31
|
const NATIVE_EVENT_BY_TYPE: Record<AdEventType, string> = {
|
|
27
32
|
[AdEventType.LOADED]: ON_APPOPEN_AD_LOADED_EVENT,
|
|
@@ -34,24 +39,44 @@ const NATIVE_EVENT_BY_TYPE: Record<AdEventType, string> = {
|
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
export class AppOpenAd {
|
|
42
|
+
private static _nextRequestId = 1;
|
|
43
|
+
private static _legacyRequestIds = new Map<string, number>();
|
|
44
|
+
private static _legacyRequestIdSet = new Set<number>();
|
|
45
|
+
|
|
37
46
|
private readonly eventEmitter = new AdEventEmitter();
|
|
38
47
|
|
|
39
|
-
private constructor(
|
|
48
|
+
private constructor(
|
|
49
|
+
private readonly requestId: number,
|
|
50
|
+
private readonly adUnitId: string
|
|
51
|
+
) {}
|
|
40
52
|
|
|
41
53
|
static createForAdRequest(adUnitId: string): AppOpenAd {
|
|
42
|
-
|
|
54
|
+
const requestId = AppOpenAd._nextRequestId++;
|
|
55
|
+
return new AppOpenAd(requestId, adUnitId);
|
|
43
56
|
}
|
|
44
57
|
|
|
45
58
|
isAdReady(): Promise<boolean> {
|
|
46
|
-
|
|
59
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
60
|
+
return Promise.resolve(false);
|
|
61
|
+
}
|
|
62
|
+
return NativeDaroModule.isAppOpenAdReady(this.requestId, this.adUnitId);
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
load(): void {
|
|
50
|
-
|
|
66
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
67
|
+
warnUnsupportedPlatform();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
NativeDaroModule.loadAppOpenAd(this.requestId, this.adUnitId);
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
show(placement?: string | null, customData?: string | null): void {
|
|
54
|
-
|
|
74
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
75
|
+
warnUnsupportedPlatform();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
NativeDaroModule.showAppOpenAd(
|
|
79
|
+
this.requestId,
|
|
55
80
|
this.adUnitId,
|
|
56
81
|
placement ?? undefined,
|
|
57
82
|
customData ?? undefined
|
|
@@ -62,10 +87,15 @@ export class AppOpenAd {
|
|
|
62
87
|
type: T,
|
|
63
88
|
listener: (info: AdEventPayloadMap[T]) => void
|
|
64
89
|
): () => void {
|
|
90
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
91
|
+
warnUnsupportedPlatform();
|
|
92
|
+
return () => {};
|
|
93
|
+
}
|
|
94
|
+
|
|
65
95
|
const nativeEvent = NATIVE_EVENT_BY_TYPE[type];
|
|
66
|
-
const
|
|
96
|
+
const requestId = this.requestId;
|
|
67
97
|
return this.eventEmitter.addEventListener(nativeEvent, (payload: any) => {
|
|
68
|
-
if (payload?.
|
|
98
|
+
if (payload?.requestId !== requestId) {
|
|
69
99
|
return;
|
|
70
100
|
}
|
|
71
101
|
listener(payload);
|
|
@@ -78,14 +108,50 @@ export class AppOpenAd {
|
|
|
78
108
|
|
|
79
109
|
// ---- Deprecated static API (backward compatibility) ----
|
|
80
110
|
|
|
111
|
+
private static _getLegacyRequestId(adUnitId: string): number {
|
|
112
|
+
let requestId = AppOpenAd._legacyRequestIds.get(adUnitId);
|
|
113
|
+
if (requestId === undefined) {
|
|
114
|
+
requestId = AppOpenAd._nextRequestId++;
|
|
115
|
+
AppOpenAd._legacyRequestIds.set(adUnitId, requestId);
|
|
116
|
+
AppOpenAd._legacyRequestIdSet.add(requestId);
|
|
117
|
+
}
|
|
118
|
+
return requestId;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private static _addLegacyEventListener<T>(
|
|
122
|
+
event: string,
|
|
123
|
+
listener: (info: T) => void
|
|
124
|
+
): void {
|
|
125
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
126
|
+
warnUnsupportedPlatform();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
addEventListener(event, (payload: any) => {
|
|
131
|
+
if (!AppOpenAd._legacyRequestIdSet.has(payload?.requestId)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
listener(payload);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
81
138
|
/** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
|
|
82
139
|
static isAdReady(adUnitId: string): Promise<boolean> {
|
|
83
|
-
|
|
140
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
141
|
+
return Promise.resolve(false);
|
|
142
|
+
}
|
|
143
|
+
const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
|
|
144
|
+
return NativeDaroModule.isAppOpenAdReady(requestId, adUnitId);
|
|
84
145
|
}
|
|
85
146
|
|
|
86
147
|
/** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
|
|
87
148
|
static loadAd(adUnitId: string): void {
|
|
88
|
-
|
|
149
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
150
|
+
warnUnsupportedPlatform();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
|
|
154
|
+
NativeDaroModule.loadAppOpenAd(requestId, adUnitId);
|
|
89
155
|
}
|
|
90
156
|
|
|
91
157
|
/** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
|
|
@@ -94,7 +160,13 @@ export class AppOpenAd {
|
|
|
94
160
|
placement?: string | null,
|
|
95
161
|
customData?: string | null
|
|
96
162
|
): void {
|
|
97
|
-
|
|
163
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
164
|
+
warnUnsupportedPlatform();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
|
|
168
|
+
NativeDaroModule.showAppOpenAd(
|
|
169
|
+
requestId,
|
|
98
170
|
adUnitId,
|
|
99
171
|
placement ?? undefined,
|
|
100
172
|
customData ?? undefined
|
|
@@ -103,7 +175,7 @@ export class AppOpenAd {
|
|
|
103
175
|
|
|
104
176
|
/** @deprecated `addAdEventListener(AdEventType.LOADED, ...)`를 인스턴스에서 사용하세요. */
|
|
105
177
|
static addAdLoadedEventListener(listener: (adInfo: AdInfo) => void): void {
|
|
106
|
-
|
|
178
|
+
AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_LOADED_EVENT, listener);
|
|
107
179
|
}
|
|
108
180
|
|
|
109
181
|
/** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
|
|
@@ -115,7 +187,10 @@ export class AppOpenAd {
|
|
|
115
187
|
static addAdLoadFailedEventListener(
|
|
116
188
|
listener: (errorInfo: AdLoadFailedInfo) => void
|
|
117
189
|
): void {
|
|
118
|
-
|
|
190
|
+
AppOpenAd._addLegacyEventListener(
|
|
191
|
+
ON_APPOPEN_AD_LOAD_FAILED_EVENT,
|
|
192
|
+
listener
|
|
193
|
+
);
|
|
119
194
|
}
|
|
120
195
|
|
|
121
196
|
/** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
|
|
@@ -125,7 +200,7 @@ export class AppOpenAd {
|
|
|
125
200
|
|
|
126
201
|
/** @deprecated `addAdEventListener(AdEventType.CLICKED, ...)`를 인스턴스에서 사용하세요. */
|
|
127
202
|
static addAdClickedEventListener(listener: (adInfo: AdInfo) => void): void {
|
|
128
|
-
|
|
203
|
+
AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_CLICKED_EVENT, listener);
|
|
129
204
|
}
|
|
130
205
|
|
|
131
206
|
/** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
|
|
@@ -135,7 +210,7 @@ export class AppOpenAd {
|
|
|
135
210
|
|
|
136
211
|
/** @deprecated `addAdEventListener(AdEventType.DISPLAYED, ...)`를 인스턴스에서 사용하세요. */
|
|
137
212
|
static addAdDisplayedEventListener(listener: (adInfo: AdInfo) => void): void {
|
|
138
|
-
|
|
213
|
+
AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_DISPLAYED_EVENT, listener);
|
|
139
214
|
}
|
|
140
215
|
|
|
141
216
|
/** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
|
|
@@ -147,7 +222,10 @@ export class AppOpenAd {
|
|
|
147
222
|
static addAdFailedToDisplayEventListener(
|
|
148
223
|
listener: (errorInfo: AdDisplayFailedInfo) => void
|
|
149
224
|
): void {
|
|
150
|
-
|
|
225
|
+
AppOpenAd._addLegacyEventListener(
|
|
226
|
+
ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
|
|
227
|
+
listener
|
|
228
|
+
);
|
|
151
229
|
}
|
|
152
230
|
|
|
153
231
|
/** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
|
|
@@ -157,7 +235,7 @@ export class AppOpenAd {
|
|
|
157
235
|
|
|
158
236
|
/** @deprecated `addAdEventListener(AdEventType.HIDDEN, ...)`를 인스턴스에서 사용하세요. */
|
|
159
237
|
static addAdHiddenEventListener(listener: (adInfo: AdInfo) => void): void {
|
|
160
|
-
|
|
238
|
+
AppOpenAd._addLegacyEventListener(ON_APPOPEN_AD_HIDDEN_EVENT, listener);
|
|
161
239
|
}
|
|
162
240
|
|
|
163
241
|
/** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
|
|
@@ -169,7 +247,10 @@ export class AppOpenAd {
|
|
|
169
247
|
static addAdImpressionRecordedListener(
|
|
170
248
|
listener: (adInfo: AdInfo) => void
|
|
171
249
|
): void {
|
|
172
|
-
|
|
250
|
+
AppOpenAd._addLegacyEventListener(
|
|
251
|
+
ON_APPOPEN_AD_IMPRESSION_RECORDED,
|
|
252
|
+
listener
|
|
253
|
+
);
|
|
173
254
|
}
|
|
174
255
|
|
|
175
256
|
/** @deprecated 인스턴스의 `addAdEventListener` disposer를 사용하세요. */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires these imports. */
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
4
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
5
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
6
|
+
import type {
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
Double,
|
|
9
|
+
Int32,
|
|
10
|
+
WithDefault,
|
|
11
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
12
|
+
|
|
13
|
+
type AdInfoPayload = {
|
|
14
|
+
adUnitId: string;
|
|
15
|
+
latencyMillis: Double;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type AdLoadFailedInfoPayload = {
|
|
19
|
+
adUnitId: string;
|
|
20
|
+
code: Int32;
|
|
21
|
+
message: string;
|
|
22
|
+
latencyMillis: Double;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface NativeProps extends ViewProps {
|
|
26
|
+
adUnitId: string;
|
|
27
|
+
adFormat: string;
|
|
28
|
+
placement?: string | null;
|
|
29
|
+
loadOnMount?: WithDefault<boolean, true>;
|
|
30
|
+
isVisible?: WithDefault<boolean, true>;
|
|
31
|
+
onAdLoadedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
32
|
+
onAdLoadFailedEvent?: DirectEventHandler<AdLoadFailedInfoPayload>;
|
|
33
|
+
onAdClickedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
34
|
+
onAdImpressionRecordedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
38
|
+
|
|
39
|
+
interface NativeCommands {
|
|
40
|
+
loadAd: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
44
|
+
supportedCommands: ['loadAd'],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export default codegenNativeComponent<NativeProps>('DaroMAdBannerView');
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires these imports. */
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
4
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
5
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
6
|
+
import type {
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
Double,
|
|
9
|
+
Int32,
|
|
10
|
+
UnsafeMixed,
|
|
11
|
+
WithDefault,
|
|
12
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
13
|
+
|
|
14
|
+
type AdInfoPayload = {
|
|
15
|
+
adUnitId: string;
|
|
16
|
+
latencyMillis: Double;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type AdLoadFailedInfoPayload = {
|
|
20
|
+
adUnitId: string;
|
|
21
|
+
code: Int32;
|
|
22
|
+
message: string;
|
|
23
|
+
latencyMillis: Double;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type AdChoicesPosition = 'topLeft' | 'topRight' | 'bottomRight' | 'bottomLeft';
|
|
27
|
+
|
|
28
|
+
export interface NativeProps extends ViewProps {
|
|
29
|
+
adUnitId: string;
|
|
30
|
+
placement?: string | null;
|
|
31
|
+
loadOnMount?: WithDefault<boolean, true>;
|
|
32
|
+
adChoicesPosition?: WithDefault<AdChoicesPosition, 'bottomRight'>;
|
|
33
|
+
|
|
34
|
+
titleView?: Int32;
|
|
35
|
+
bodyView?: Int32;
|
|
36
|
+
callToActionView?: Int32;
|
|
37
|
+
iconView?: Int32;
|
|
38
|
+
mediaView?: Int32;
|
|
39
|
+
|
|
40
|
+
titleViewStyleProps?: UnsafeMixed;
|
|
41
|
+
bodyViewStyleProps?: UnsafeMixed;
|
|
42
|
+
callToActionViewStyleProps?: UnsafeMixed;
|
|
43
|
+
iconViewStyleProps?: UnsafeMixed;
|
|
44
|
+
mediaViewStyleProps?: UnsafeMixed;
|
|
45
|
+
|
|
46
|
+
onAdLoadedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
47
|
+
onAdLoadFailedEvent?: DirectEventHandler<AdLoadFailedInfoPayload>;
|
|
48
|
+
onAdClickedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
49
|
+
onAdImpressionRecordedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
53
|
+
|
|
54
|
+
interface NativeCommands {
|
|
55
|
+
loadAd: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
59
|
+
supportedCommands: ['loadAd'],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export default codegenNativeComponent<NativeProps>('DaroMNativeAdView');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires this import. */
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
4
|
+
|
|
5
|
+
export interface NativeProps extends ViewProps {}
|
|
6
|
+
|
|
7
|
+
export default codegenNativeComponent<NativeProps>('DaroMediaView', {
|
|
8
|
+
excludedPlatforms: ['iOS'],
|
|
9
|
+
});
|
package/src/ErrorCode.ts
CHANGED
package/src/EventEmitter.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NativeEventEmitter } from 'react-native';
|
|
2
2
|
import type { EventSubscription } from 'react-native';
|
|
3
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
3
4
|
import type { AdEventObject, AdEventListener } from './types/AdEvent';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const emitter = new NativeEventEmitter(DaroMModule);
|
|
6
|
+
const emitter = new NativeEventEmitter(NativeDaroModule);
|
|
8
7
|
const subscriptions: Map<string, Set<EventSubscription>> = new Map();
|
|
9
8
|
|
|
10
9
|
export const addEventListener = <T extends AdEventObject>(
|
|
11
10
|
event: string,
|
|
12
11
|
handler: AdEventListener<T>
|
|
13
12
|
): (() => void) => {
|
|
14
|
-
const subscription: EventSubscription = emitter.addListener(
|
|
13
|
+
const subscription: EventSubscription = emitter.addListener(
|
|
14
|
+
event,
|
|
15
|
+
handler as (...args: Object[]) => void
|
|
16
|
+
);
|
|
15
17
|
|
|
16
18
|
if (!subscriptions.has(event)) {
|
|
17
19
|
subscriptions.set(event, new Set());
|
|
@@ -34,7 +36,7 @@ export class AdEventEmitter {
|
|
|
34
36
|
private subscriptions: Map<string, Set<EventSubscription>> = new Map();
|
|
35
37
|
|
|
36
38
|
constructor() {
|
|
37
|
-
this.emitter = new NativeEventEmitter(
|
|
39
|
+
this.emitter = new NativeEventEmitter(NativeDaroModule);
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
addEventListener<T extends AdEventObject>(
|
|
@@ -43,7 +45,7 @@ export class AdEventEmitter {
|
|
|
43
45
|
): () => void {
|
|
44
46
|
const subscription: EventSubscription = this.emitter.addListener(
|
|
45
47
|
event,
|
|
46
|
-
handler
|
|
48
|
+
handler as (...args: Object[]) => void
|
|
47
49
|
);
|
|
48
50
|
|
|
49
51
|
if (!this.subscriptions.has(event)) {
|