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
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type ElementRef,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { View, type ViewProps } from 'react-native';
|
|
12
|
+
import NativeAdViewNativeComponent, {
|
|
13
|
+
Commands,
|
|
14
|
+
} from '../DaroMNativeAdViewNativeComponent';
|
|
15
|
+
import NativeDaroModule from '../NativeDaroModule';
|
|
3
16
|
import type { AdNativeEvent } from '../types/AdEvent';
|
|
4
17
|
import type { AdInfo, AdLoadFailedInfo } from '../types/AdInfo';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export const NativeAdView = forwardRef<NativeAdViewHandler, NativeAdViewProps & ViewProps>(function NativeAdView(props, ref) {
|
|
18
|
+
import type {
|
|
19
|
+
NativeAdViewHandler,
|
|
20
|
+
NativeAdViewProps,
|
|
21
|
+
} from '../types/NativeAdViewProps';
|
|
22
|
+
import {
|
|
23
|
+
NativeAdViewContext,
|
|
24
|
+
NativeAdViewProvider,
|
|
25
|
+
} from './NativeAdViewProvider';
|
|
26
|
+
|
|
27
|
+
type NativeAdViewElement = ElementRef<typeof NativeAdViewNativeComponent>;
|
|
28
|
+
|
|
29
|
+
export const NativeAdView = forwardRef<
|
|
30
|
+
NativeAdViewHandler,
|
|
31
|
+
NativeAdViewProps & ViewProps
|
|
32
|
+
>(function NativeAdView(props, ref) {
|
|
21
33
|
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
22
34
|
|
|
23
35
|
useEffect(() => {
|
|
24
36
|
const checkInitialization = async () => {
|
|
25
|
-
const result = await
|
|
37
|
+
const result = await NativeDaroModule.isInitialized();
|
|
26
38
|
setIsInitialized(result);
|
|
27
39
|
if (!result) {
|
|
28
|
-
console.warn(
|
|
40
|
+
console.warn(
|
|
41
|
+
'NativeAdView is mounted before the initialization of the DaroM React Native module.'
|
|
42
|
+
);
|
|
29
43
|
}
|
|
30
44
|
};
|
|
31
45
|
|
|
@@ -41,42 +55,43 @@ export const NativeAdView = forwardRef<NativeAdViewHandler, NativeAdViewProps &
|
|
|
41
55
|
<NativeAdViewProvider>
|
|
42
56
|
<NativeAdViewImpl {...props} ref={ref} />
|
|
43
57
|
</NativeAdViewProvider>
|
|
44
|
-
);
|
|
58
|
+
);
|
|
45
59
|
});
|
|
46
60
|
|
|
47
|
-
const NativeAdViewImpl = forwardRef<
|
|
48
|
-
|
|
61
|
+
const NativeAdViewImpl = forwardRef<
|
|
62
|
+
NativeAdViewHandler,
|
|
63
|
+
NativeAdViewProps & ViewProps
|
|
64
|
+
>(function NativeAdViewImpl(
|
|
65
|
+
{
|
|
66
|
+
adUnitId,
|
|
67
|
+
onAdLoaded,
|
|
68
|
+
onAdLoadFailed,
|
|
69
|
+
onAdClicked,
|
|
70
|
+
onAdImpressionRecorded,
|
|
71
|
+
children,
|
|
72
|
+
style,
|
|
73
|
+
loadOnMount = true,
|
|
74
|
+
adChoicesPosition = 'bottomRight',
|
|
75
|
+
...otherProps
|
|
76
|
+
},
|
|
49
77
|
ref
|
|
50
78
|
) {
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const nativeAdViewRef = useRef<NativeAdViewType | null>(null);
|
|
79
|
+
const { nativeAdAssetRegistrations } = useContext(NativeAdViewContext);
|
|
80
|
+
const nativeAdViewRef = useRef<NativeAdViewElement | null>(null);
|
|
55
81
|
|
|
56
82
|
// Load a new ad
|
|
57
83
|
const loadAd = useCallback(() => {
|
|
58
84
|
if (nativeAdViewRef.current) {
|
|
59
|
-
|
|
60
|
-
findNodeHandle(nativeAdViewRef.current),
|
|
61
|
-
// @ts-ignore: Issue in RN ts defs
|
|
62
|
-
UIManager.getViewManagerConfig(ComponentName).Commands.loadAd,
|
|
63
|
-
[],
|
|
64
|
-
);
|
|
85
|
+
Commands.loadAd(nativeAdViewRef.current);
|
|
65
86
|
}
|
|
66
87
|
}, []);
|
|
67
88
|
|
|
68
89
|
useImperativeHandle(ref, () => ({ loadAd }), [loadAd]);
|
|
69
90
|
|
|
70
91
|
// Save the DOM element reference
|
|
71
|
-
const saveElement = useCallback(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
nativeAdViewRef.current = element;
|
|
75
|
-
setNativeAdView(element);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
[setNativeAdView]
|
|
79
|
-
);
|
|
92
|
+
const saveElement = useCallback((element: NativeAdViewElement | null) => {
|
|
93
|
+
nativeAdViewRef.current = element;
|
|
94
|
+
}, []);
|
|
80
95
|
|
|
81
96
|
const onAdLoadedEvent = useCallback(
|
|
82
97
|
(event: AdNativeEvent<AdInfo>) => {
|
|
@@ -107,18 +122,41 @@ const NativeAdViewImpl = forwardRef<NativeAdViewHandler, NativeAdViewProps & Vie
|
|
|
107
122
|
);
|
|
108
123
|
|
|
109
124
|
return (
|
|
110
|
-
<
|
|
125
|
+
<NativeAdViewNativeComponent
|
|
111
126
|
ref={saveElement}
|
|
127
|
+
{...otherProps}
|
|
112
128
|
adUnitId={adUnitId}
|
|
113
129
|
loadOnMount={loadOnMount}
|
|
130
|
+
adChoicesPosition={adChoicesPosition}
|
|
131
|
+
titleView={nativeAdAssetRegistrations.titleView?.nativeTag ?? 0}
|
|
132
|
+
bodyView={nativeAdAssetRegistrations.bodyView?.nativeTag ?? 0}
|
|
133
|
+
callToActionView={
|
|
134
|
+
nativeAdAssetRegistrations.callToActionView?.nativeTag ?? 0
|
|
135
|
+
}
|
|
136
|
+
iconView={nativeAdAssetRegistrations.iconView?.nativeTag ?? 0}
|
|
137
|
+
mediaView={nativeAdAssetRegistrations.mediaView?.nativeTag ?? 0}
|
|
138
|
+
titleViewStyleProps={
|
|
139
|
+
nativeAdAssetRegistrations.titleView?.styleProps ?? null
|
|
140
|
+
}
|
|
141
|
+
bodyViewStyleProps={
|
|
142
|
+
nativeAdAssetRegistrations.bodyView?.styleProps ?? null
|
|
143
|
+
}
|
|
144
|
+
callToActionViewStyleProps={
|
|
145
|
+
nativeAdAssetRegistrations.callToActionView?.styleProps ?? null
|
|
146
|
+
}
|
|
147
|
+
iconViewStyleProps={
|
|
148
|
+
nativeAdAssetRegistrations.iconView?.styleProps ?? null
|
|
149
|
+
}
|
|
150
|
+
mediaViewStyleProps={
|
|
151
|
+
nativeAdAssetRegistrations.mediaView?.styleProps ?? null
|
|
152
|
+
}
|
|
114
153
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
115
154
|
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
116
155
|
onAdClickedEvent={onAdClickedEvent}
|
|
117
156
|
onAdImpressionRecordedEvent={onAdImpressionRecordedEvent}
|
|
118
157
|
style={style}
|
|
119
|
-
{...otherProps}
|
|
120
158
|
>
|
|
121
159
|
{children}
|
|
122
|
-
</
|
|
160
|
+
</NativeAdViewNativeComponent>
|
|
123
161
|
);
|
|
124
162
|
});
|
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
type ComponentRef,
|
|
4
|
+
useContext,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import type {
|
|
10
|
+
ImageProps,
|
|
11
|
+
StyleProp,
|
|
12
|
+
TextProps,
|
|
13
|
+
TextStyle,
|
|
14
|
+
ImageStyle,
|
|
15
|
+
ViewStyle,
|
|
16
|
+
ViewProps,
|
|
17
|
+
} from 'react-native';
|
|
18
|
+
import {
|
|
19
|
+
findNodeHandle,
|
|
20
|
+
Image,
|
|
21
|
+
Platform,
|
|
22
|
+
StyleSheet,
|
|
23
|
+
Text,
|
|
24
|
+
UIManager,
|
|
25
|
+
View,
|
|
26
|
+
} from 'react-native';
|
|
27
|
+
import {
|
|
28
|
+
NativeAdViewContext,
|
|
29
|
+
type NativeAdViewAssetPropKey,
|
|
30
|
+
} from './NativeAdViewProvider';
|
|
31
|
+
import DaroMediaViewNativeComponent from '../DaroMediaViewNativeComponent';
|
|
32
|
+
|
|
33
|
+
const UNREGISTERED_NATIVE_TAG = 0;
|
|
6
34
|
|
|
7
35
|
// 스타일 속성 추출을 위한 타입 정의
|
|
8
36
|
type StyleProps = {
|
|
@@ -53,41 +81,52 @@ type StyleProps = {
|
|
|
53
81
|
};
|
|
54
82
|
|
|
55
83
|
// 스타일 속성 추출 커스텀 훅
|
|
56
|
-
const useStyleProps = (
|
|
84
|
+
const useStyleProps = (
|
|
85
|
+
style: StyleProp<TextStyle | ViewStyle>,
|
|
86
|
+
textProps?: Pick<TextProps, 'numberOfLines' | 'ellipsizeMode'>
|
|
87
|
+
): StyleProps => {
|
|
57
88
|
return useMemo(() => {
|
|
58
|
-
const styleObj = style as TextStyle;
|
|
89
|
+
const styleObj = (StyleSheet.flatten(style) ?? {}) as TextStyle & ViewStyle;
|
|
90
|
+
|
|
59
91
|
return {
|
|
60
92
|
// 1. 폰트 관련
|
|
61
93
|
fontSize: styleObj.fontSize as number,
|
|
62
94
|
fontWeight: styleObj.fontWeight as string,
|
|
63
95
|
fontFamily: styleObj.fontFamily as string,
|
|
64
96
|
color: styleObj.color as string,
|
|
65
|
-
|
|
97
|
+
|
|
66
98
|
// 2. 배경색
|
|
67
99
|
backgroundColor: styleObj.backgroundColor as string,
|
|
68
|
-
|
|
100
|
+
|
|
69
101
|
// 3. 정렬
|
|
70
|
-
textAlign: styleObj.textAlign as
|
|
71
|
-
|
|
102
|
+
textAlign: styleObj.textAlign as
|
|
103
|
+
| 'auto'
|
|
104
|
+
| 'left'
|
|
105
|
+
| 'right'
|
|
106
|
+
| 'center'
|
|
107
|
+
| 'justify',
|
|
108
|
+
numberOfLines: textProps?.numberOfLines,
|
|
109
|
+
lineBreakMode: textProps?.ellipsizeMode as StyleProps['lineBreakMode'],
|
|
110
|
+
|
|
72
111
|
// 6. 투명도
|
|
73
112
|
opacity: styleObj.opacity as number,
|
|
74
|
-
|
|
113
|
+
|
|
75
114
|
// 7. 숨김
|
|
76
115
|
display: styleObj.display as 'none' | 'flex',
|
|
77
|
-
|
|
116
|
+
|
|
78
117
|
// 10. 모서리 둥글게
|
|
79
118
|
borderRadius: styleObj.borderRadius as number,
|
|
80
|
-
|
|
119
|
+
|
|
81
120
|
// 11. 테두리
|
|
82
121
|
borderWidth: styleObj.borderWidth as number,
|
|
83
122
|
borderColor: styleObj.borderColor as string,
|
|
84
|
-
|
|
123
|
+
|
|
85
124
|
// 12. 그림자
|
|
86
125
|
shadowColor: styleObj.shadowColor as string,
|
|
87
126
|
shadowOffset: styleObj.shadowOffset as { width: number; height: number },
|
|
88
127
|
shadowOpacity: styleObj.shadowOpacity as number,
|
|
89
128
|
shadowRadius: styleObj.shadowRadius as number,
|
|
90
|
-
|
|
129
|
+
|
|
91
130
|
// 13. 여백
|
|
92
131
|
padding: styleObj.padding as number,
|
|
93
132
|
margin: styleObj.margin as number,
|
|
@@ -99,27 +138,27 @@ const useStyleProps = (style: StyleProp<TextStyle>): StyleProps => {
|
|
|
99
138
|
marginRight: styleObj.marginRight as number,
|
|
100
139
|
marginBottom: styleObj.marginBottom as number,
|
|
101
140
|
marginLeft: styleObj.marginLeft as number,
|
|
102
|
-
|
|
141
|
+
|
|
103
142
|
// 14. 위치
|
|
104
143
|
position: styleObj.position as 'absolute' | 'relative',
|
|
105
144
|
top: styleObj.top as number,
|
|
106
145
|
right: styleObj.right as number,
|
|
107
146
|
bottom: styleObj.bottom as number,
|
|
108
147
|
left: styleObj.left as number,
|
|
109
|
-
|
|
148
|
+
|
|
110
149
|
// 15. 크기
|
|
111
|
-
width: styleObj.width as number,
|
|
112
|
-
height: styleObj.height as number,
|
|
113
|
-
|
|
150
|
+
width: styleObj.width as number | string,
|
|
151
|
+
height: styleObj.height as number | string,
|
|
152
|
+
|
|
114
153
|
// 16. 변환
|
|
115
154
|
transform: styleObj.transform as any[],
|
|
116
|
-
|
|
155
|
+
|
|
117
156
|
// 17. 기타
|
|
118
157
|
zIndex: styleObj.zIndex as number,
|
|
119
158
|
overflow: styleObj.overflow as 'visible' | 'hidden' | 'scroll',
|
|
120
159
|
backfaceVisibility: styleObj.backfaceVisibility as 'visible' | 'hidden',
|
|
121
160
|
};
|
|
122
|
-
}, [style]);
|
|
161
|
+
}, [style, textProps?.ellipsizeMode, textProps?.numberOfLines]);
|
|
123
162
|
};
|
|
124
163
|
|
|
125
164
|
// Image 스타일 속성을 위한 타입 정의 추가
|
|
@@ -138,7 +177,8 @@ type ImageStyleProps = StyleProps & {
|
|
|
138
177
|
// Image 스타일 속성 추출 커스텀 훅
|
|
139
178
|
const useImageStyleProps = (style: StyleProp<ImageStyle>): ImageStyleProps => {
|
|
140
179
|
return useMemo(() => {
|
|
141
|
-
const styleObj = style
|
|
180
|
+
const styleObj = StyleSheet.flatten(style) ?? {};
|
|
181
|
+
|
|
142
182
|
return {
|
|
143
183
|
// 기본 스타일 속성
|
|
144
184
|
backgroundColor: styleObj.backgroundColor as string,
|
|
@@ -151,11 +191,16 @@ const useImageStyleProps = (style: StyleProp<ImageStyle>): ImageStyleProps => {
|
|
|
151
191
|
shadowOpacity: styleObj.shadowOpacity as number,
|
|
152
192
|
shadowRadius: styleObj.shadowRadius as number,
|
|
153
193
|
|
|
154
|
-
width: styleObj.width as number,
|
|
155
|
-
height: styleObj.height as number,
|
|
194
|
+
width: styleObj.width as number | string,
|
|
195
|
+
height: styleObj.height as number | string,
|
|
156
196
|
|
|
157
197
|
// Image 전용 스타일 속성
|
|
158
|
-
resizeMode: styleObj.resizeMode as
|
|
198
|
+
resizeMode: styleObj.resizeMode as
|
|
199
|
+
| 'cover'
|
|
200
|
+
| 'contain'
|
|
201
|
+
| 'stretch'
|
|
202
|
+
| 'repeat'
|
|
203
|
+
| 'center',
|
|
159
204
|
tintColor: styleObj.tintColor as string,
|
|
160
205
|
overlayColor: styleObj.overlayColor as string,
|
|
161
206
|
aspectRatio: styleObj.aspectRatio as number,
|
|
@@ -163,37 +208,47 @@ const useImageStyleProps = (style: StyleProp<ImageStyle>): ImageStyleProps => {
|
|
|
163
208
|
}, [style]);
|
|
164
209
|
};
|
|
165
210
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
211
|
+
type NativeAdAssetStyleProps = StyleProps | ImageStyleProps;
|
|
212
|
+
|
|
213
|
+
// 네이티브 광고 자산 등록 커스텀 훅
|
|
214
|
+
const useNativeAdAssetRegistration = (
|
|
215
|
+
ref: React.RefObject<any>,
|
|
216
|
+
nativePropKey: NativeAdViewAssetPropKey,
|
|
217
|
+
styleProps?: NativeAdAssetStyleProps
|
|
218
|
+
) => {
|
|
219
|
+
const { registerNativeAdAsset, unregisterNativeAdAsset } =
|
|
220
|
+
useContext(NativeAdViewContext);
|
|
221
|
+
|
|
222
|
+
useLayoutEffect(() => {
|
|
223
|
+
const nativeTag = ref.current
|
|
224
|
+
? (findNodeHandle(ref.current) ?? UNREGISTERED_NATIVE_TAG)
|
|
225
|
+
: UNREGISTERED_NATIVE_TAG;
|
|
169
226
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
227
|
+
registerNativeAdAsset(nativePropKey, nativeTag, styleProps ?? null);
|
|
228
|
+
}, [nativePropKey, ref, registerNativeAdAsset, styleProps]);
|
|
229
|
+
|
|
230
|
+
useLayoutEffect(() => {
|
|
231
|
+
return () => {
|
|
232
|
+
unregisterNativeAdAsset(nativePropKey);
|
|
174
233
|
};
|
|
175
|
-
|
|
176
|
-
if (styleProps) {
|
|
177
|
-
props[`${nativePropKey}StyleProps`] = styleProps;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
nativeAdView?.setNativeProps(props);
|
|
181
|
-
}, [nativeAdView, ref, nativePropKey, styleProps]);
|
|
182
|
-
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
setNativeProps();
|
|
185
|
-
}, [setNativeProps]);
|
|
234
|
+
}, [nativePropKey, unregisterNativeAdAsset]);
|
|
186
235
|
};
|
|
187
236
|
|
|
188
237
|
// 공통 Text 컴포넌트
|
|
189
|
-
const AdTextView = (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
238
|
+
const AdTextView = (
|
|
239
|
+
props: TextProps & { nativePropKey: NativeAdViewAssetPropKey }
|
|
240
|
+
) => {
|
|
241
|
+
const { nativePropKey, children, ...restProps } = props;
|
|
242
|
+
const textRef = useRef<ComponentRef<typeof Text> | null>(null);
|
|
243
|
+
const styleProps = useStyleProps(props.style, props);
|
|
244
|
+
|
|
245
|
+
useNativeAdAssetRegistration(textRef, nativePropKey, styleProps);
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<Text {...restProps} ref={textRef}>
|
|
249
|
+
{children ?? (Platform.OS === 'android' ? ' ' : undefined)}
|
|
250
|
+
</Text>
|
|
251
|
+
);
|
|
197
252
|
};
|
|
198
253
|
|
|
199
254
|
export const TitleView = (props: TextProps) => {
|
|
@@ -205,14 +260,19 @@ export const BodyView = (props: TextProps) => {
|
|
|
205
260
|
};
|
|
206
261
|
|
|
207
262
|
export const CallToActionView = (props: TextProps) => {
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
263
|
+
const { children, ...restProps } = props;
|
|
264
|
+
const callToActionRef = useRef<ComponentRef<typeof Text> | null>(null);
|
|
265
|
+
const styleProps = useStyleProps(props.style, props);
|
|
266
|
+
|
|
267
|
+
useNativeAdAssetRegistration(callToActionRef, 'callToActionView', styleProps);
|
|
268
|
+
|
|
213
269
|
// TouchableOpacity disables clicking on certain Android devices.
|
|
214
270
|
if (Platform.OS === 'android') {
|
|
215
|
-
return
|
|
271
|
+
return (
|
|
272
|
+
<Text {...restProps} ref={callToActionRef}>
|
|
273
|
+
{children ?? ' '}
|
|
274
|
+
</Text>
|
|
275
|
+
);
|
|
216
276
|
} else {
|
|
217
277
|
return (
|
|
218
278
|
<View>
|
|
@@ -223,17 +283,22 @@ export const CallToActionView = (props: TextProps) => {
|
|
|
223
283
|
};
|
|
224
284
|
|
|
225
285
|
export const IconView = (props: Omit<ImageProps, 'source'>) => {
|
|
226
|
-
const imageRef = useRef<Image | null>(null);
|
|
286
|
+
const imageRef = useRef<ComponentRef<typeof Image> | null>(null);
|
|
227
287
|
const iconViewStyleProps = useImageStyleProps(props.style);
|
|
228
|
-
|
|
288
|
+
useNativeAdAssetRegistration(imageRef, 'iconView', iconViewStyleProps);
|
|
229
289
|
|
|
230
290
|
return <Image {...props} ref={imageRef} source={0} />;
|
|
231
291
|
};
|
|
232
292
|
|
|
293
|
+
const NativeMediaView =
|
|
294
|
+
Platform.OS === 'android' && UIManager.hasViewManagerConfig?.('DaroMediaView')
|
|
295
|
+
? DaroMediaViewNativeComponent
|
|
296
|
+
: View;
|
|
297
|
+
|
|
233
298
|
export const MediaView = (props: ViewProps) => {
|
|
234
|
-
const viewRef = useRef<View | null>(null);
|
|
235
|
-
|
|
299
|
+
const viewRef = useRef<ComponentRef<typeof View> | null>(null);
|
|
300
|
+
const mediaViewStyleProps = useStyleProps(props.style);
|
|
301
|
+
useNativeAdAssetRegistration(viewRef, 'mediaView', mediaViewStyleProps);
|
|
236
302
|
|
|
237
|
-
return <
|
|
303
|
+
return <NativeMediaView {...props} ref={viewRef} collapsable={false} />;
|
|
238
304
|
};
|
|
239
|
-
|
|
@@ -1,32 +1,100 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { createContext, useState } from 'react';
|
|
4
|
-
import type { NativeMethods } from 'react-native';
|
|
5
|
-
import type { NativeAdViewProps } from '../types/NativeAdViewProps';
|
|
3
|
+
import { createContext, useCallback, useMemo, useState } from 'react';
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
type NativeAdAssetStyleProps = object | null;
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
type NativeAdAssetRegistration = {
|
|
8
|
+
nativeTag: number;
|
|
9
|
+
styleProps: NativeAdAssetStyleProps;
|
|
12
10
|
};
|
|
13
11
|
|
|
12
|
+
export type NativeAdViewAssetPropKey =
|
|
13
|
+
| 'titleView'
|
|
14
|
+
| 'bodyView'
|
|
15
|
+
| 'callToActionView'
|
|
16
|
+
| 'iconView'
|
|
17
|
+
| 'mediaView';
|
|
18
|
+
|
|
19
|
+
export type NativeAdAssetRegistrations = Partial<
|
|
20
|
+
Record<NativeAdViewAssetPropKey, NativeAdAssetRegistration>
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
export type NativeAdViewContextType = {
|
|
24
|
+
nativeAdAssetRegistrations: NativeAdAssetRegistrations;
|
|
25
|
+
registerNativeAdAsset: (
|
|
26
|
+
assetKey: NativeAdViewAssetPropKey,
|
|
27
|
+
nativeTag: number,
|
|
28
|
+
styleProps: NativeAdAssetStyleProps
|
|
29
|
+
) => void;
|
|
30
|
+
unregisterNativeAdAsset: (assetKey: NativeAdViewAssetPropKey) => void;
|
|
31
|
+
};
|
|
14
32
|
|
|
15
33
|
export const NativeAdViewContext = createContext<NativeAdViewContextType>({
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
nativeAdAssetRegistrations: {},
|
|
35
|
+
registerNativeAdAsset: () => {},
|
|
36
|
+
unregisterNativeAdAsset: () => {},
|
|
18
37
|
});
|
|
19
38
|
|
|
20
|
-
export const NativeAdViewProvider: React.FC<{ children: ReactNode }> = ({
|
|
21
|
-
|
|
39
|
+
export const NativeAdViewProvider: React.FC<{ children: ReactNode }> = ({
|
|
40
|
+
children,
|
|
41
|
+
}) => {
|
|
42
|
+
const [nativeAdAssetRegistrations, setNativeAdAssetRegistrations] =
|
|
43
|
+
useState<NativeAdAssetRegistrations>({});
|
|
44
|
+
|
|
45
|
+
const registerNativeAdAsset = useCallback(
|
|
46
|
+
(
|
|
47
|
+
assetKey: NativeAdViewAssetPropKey,
|
|
48
|
+
nativeTag: number,
|
|
49
|
+
styleProps: NativeAdAssetStyleProps
|
|
50
|
+
) => {
|
|
51
|
+
setNativeAdAssetRegistrations((prev) => {
|
|
52
|
+
const current = prev[assetKey];
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
current?.nativeTag === nativeTag &&
|
|
56
|
+
current?.styleProps === styleProps
|
|
57
|
+
) {
|
|
58
|
+
return prev;
|
|
59
|
+
}
|
|
22
60
|
|
|
23
|
-
|
|
61
|
+
return {
|
|
62
|
+
...prev,
|
|
63
|
+
[assetKey]: {
|
|
64
|
+
nativeTag,
|
|
65
|
+
styleProps,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
[]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const unregisterNativeAdAsset = useCallback(
|
|
74
|
+
(assetKey: NativeAdViewAssetPropKey) => {
|
|
75
|
+
setNativeAdAssetRegistrations((prev) => {
|
|
76
|
+
if (!prev[assetKey]) return prev;
|
|
77
|
+
|
|
78
|
+
const next = { ...prev };
|
|
79
|
+
delete next[assetKey];
|
|
80
|
+
return next;
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
[]
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const providerValue = useMemo(
|
|
24
87
|
() => ({
|
|
25
|
-
|
|
26
|
-
|
|
88
|
+
nativeAdAssetRegistrations,
|
|
89
|
+
registerNativeAdAsset,
|
|
90
|
+
unregisterNativeAdAsset,
|
|
27
91
|
}),
|
|
28
|
-
[
|
|
92
|
+
[nativeAdAssetRegistrations, registerNativeAdAsset, unregisterNativeAdAsset]
|
|
29
93
|
);
|
|
30
94
|
|
|
31
|
-
return
|
|
95
|
+
return (
|
|
96
|
+
<NativeAdViewContext.Provider value={providerValue}>
|
|
97
|
+
{children}
|
|
98
|
+
</NativeAdViewContext.Provider>
|
|
99
|
+
);
|
|
32
100
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { AdFormat } from
|
|
2
|
-
import type { AdProps } from
|
|
1
|
+
import type { AdFormat } from '../AdBannerView';
|
|
2
|
+
import type { AdProps } from './AdProps';
|
|
3
3
|
|
|
4
4
|
export type AdBannerViewHandler = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/**
|
|
6
|
+
* If the {@link loadOnMount} attribute is set to false, you can call this API to start loading ads in this AdView.
|
|
7
|
+
*/
|
|
8
|
+
loadAd(): void;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export type AdBannerViewProps = AdProps & {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
12
|
+
color?: string;
|
|
13
|
+
adFormat: AdFormat;
|
|
14
|
+
loadOnMount?: boolean;
|
|
15
|
+
isVisible?: boolean;
|
|
16
|
+
};
|
package/src/types/AdInfo.ts
CHANGED
|
@@ -2,36 +2,36 @@ import type { ErrorCode } from '../ErrorCode';
|
|
|
2
2
|
|
|
3
3
|
// Represents an ad
|
|
4
4
|
export type AdInfo = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
// The ad unit ID for which this ad was loaded.
|
|
6
|
+
adUnitId: string;
|
|
7
|
+
// The total latency in milliseconds for this waterfall to finish processing.
|
|
8
|
+
latencyMillis: number;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
// Encapsulates various data for MAX load errors.
|
|
12
12
|
export type AdLoadFailedInfo = {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// The ad unit ID for which this ad was loaded.
|
|
14
|
+
adUnitId: string;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// The error code for the error.
|
|
17
|
+
code: ErrorCode;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
message: string;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// The total latency in milliseconds for this waterfall to finish processing.
|
|
22
|
+
latencyMillis: number;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
// Encapsulates various data for MAX display errors.
|
|
26
26
|
export type AdDisplayFailedInfo = {
|
|
27
|
-
|
|
27
|
+
message: string | null;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
// Represents a reward given to the user.
|
|
31
31
|
export type AdRewardInfo = {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// The reward label.
|
|
33
|
+
rewardLabel?: string | null;
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
35
|
+
// The rewarded amount.
|
|
36
|
+
rewardAmount: string;
|
|
37
|
+
};
|