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.
- package/LICENSE +20 -0
- package/README.md +47 -0
- package/android/build.gradle +99 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +7 -0
- package/android/src/main/java/com/darom/DaroMAdBannerViewManager.kt +114 -0
- package/android/src/main/java/com/darom/DaroMAdNativeViewManager.kt +133 -0
- package/android/src/main/java/com/darom/DaroMModule.kt +194 -0
- package/android/src/main/java/com/darom/DaroMPackage.kt +21 -0
- package/android/src/main/java/com/darom/constants/InternalDaroMBannerSize.kt +23 -0
- package/android/src/main/java/com/darom/event/DaroMEvent.kt +57 -0
- package/android/src/main/java/com/darom/impl/DaroMBannerViewModuleImpl.kt +10 -0
- package/android/src/main/java/com/darom/impl/DaroMInterstitialModuleImpl.kt +113 -0
- package/android/src/main/java/com/darom/impl/DaroMLightPopupModuleImpl.kt +149 -0
- package/android/src/main/java/com/darom/impl/DaroMRewardedAdModuleImpl.kt +128 -0
- package/android/src/main/java/com/darom/util/AdInfoUtil.kt +51 -0
- package/android/src/main/java/com/darom/util/EventEmitterUtil.kt +24 -0
- package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +132 -0
- package/android/src/main/java/com/darom/view/DaroMAdNativeViewContainer.kt +372 -0
- package/android/src/main/res/layout/layout_activity_transparent.xml +7 -0
- package/android/src/main/res/values/styles.xml +11 -0
- package/ios/Daro+Extensions.swift +196 -0
- package/ios/DaroM-Bridging-Header.h +6 -0
- package/ios/DaroMAdBannerViewManager.m +15 -0
- package/ios/DaroMAdBannerViewManager.swift +87 -0
- package/ios/DaroMModule+AppOpen.swift +98 -0
- package/ios/DaroMModule+Interstitial.swift +100 -0
- package/ios/DaroMModule+LightPopup.swift +166 -0
- package/ios/DaroMModule+Rewarded.swift +118 -0
- package/ios/DaroMModule.mm +45 -0
- package/ios/DaroMModule.swift +218 -0
- package/ios/DaroMNativeAdViewManager.m +26 -0
- package/ios/DaroMNativeAdViewManager.swift +291 -0
- package/lib/commonjs/AdBannerView.js +115 -0
- package/lib/commonjs/AdBannerView.js.map +1 -0
- package/lib/commonjs/AppOpenAd.js +92 -0
- package/lib/commonjs/AppOpenAd.js.map +1 -0
- package/lib/commonjs/ErrorCode.js +11 -0
- package/lib/commonjs/ErrorCode.js.map +1 -0
- package/lib/commonjs/EventEmitter.js +30 -0
- package/lib/commonjs/EventEmitter.js.map +1 -0
- package/lib/commonjs/InterstitialAd.js +92 -0
- package/lib/commonjs/InterstitialAd.js.map +1 -0
- package/lib/commonjs/LightPopupAd.js +135 -0
- package/lib/commonjs/LightPopupAd.js.map +1 -0
- package/lib/commonjs/RewardedAd.js +105 -0
- package/lib/commonjs/RewardedAd.js.map +1 -0
- package/lib/commonjs/index.js +126 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/nativeAd/NativeAdView.js +103 -0
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -0
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js +189 -0
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -0
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js +29 -0
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -0
- package/lib/commonjs/types/AdBannerViewProps.js +6 -0
- package/lib/commonjs/types/AdBannerViewProps.js.map +1 -0
- package/lib/commonjs/types/AdEvent.js +6 -0
- package/lib/commonjs/types/AdEvent.js.map +1 -0
- package/lib/commonjs/types/AdInfo.js +6 -0
- package/lib/commonjs/types/AdInfo.js.map +1 -0
- package/lib/commonjs/types/AdProps.js +6 -0
- package/lib/commonjs/types/AdProps.js.map +1 -0
- package/lib/commonjs/types/AppOpenAd.js +6 -0
- package/lib/commonjs/types/AppOpenAd.js.map +1 -0
- package/lib/commonjs/types/DaroMMobileAds.js +2 -0
- package/lib/commonjs/types/DaroMMobileAds.js.map +1 -0
- package/lib/commonjs/types/FullScreenAd.js +6 -0
- package/lib/commonjs/types/FullScreenAd.js.map +1 -0
- package/lib/commonjs/types/InterstitialAd.js +6 -0
- package/lib/commonjs/types/InterstitialAd.js.map +1 -0
- package/lib/commonjs/types/LightPopupAd.js +6 -0
- package/lib/commonjs/types/LightPopupAd.js.map +1 -0
- package/lib/commonjs/types/NativeAdViewProps.js +6 -0
- package/lib/commonjs/types/NativeAdViewProps.js.map +1 -0
- package/lib/commonjs/types/RewardedAd.js +6 -0
- package/lib/commonjs/types/RewardedAd.js.map +1 -0
- package/lib/commonjs/types/index.js +61 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/module/AdBannerView.js +111 -0
- package/lib/module/AdBannerView.js.map +1 -0
- package/lib/module/AppOpenAd.js +88 -0
- package/lib/module/AppOpenAd.js.map +1 -0
- package/lib/module/ErrorCode.js +7 -0
- package/lib/module/ErrorCode.js.map +1 -0
- package/lib/module/EventEmitter.js +24 -0
- package/lib/module/EventEmitter.js.map +1 -0
- package/lib/module/InterstitialAd.js +88 -0
- package/lib/module/InterstitialAd.js.map +1 -0
- package/lib/module/LightPopupAd.js +130 -0
- package/lib/module/LightPopupAd.js.map +1 -0
- package/lib/module/RewardedAd.js +101 -0
- package/lib/module/RewardedAd.js.map +1 -0
- package/lib/module/index.js +30 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/nativeAd/NativeAdView.js +99 -0
- package/lib/module/nativeAd/NativeAdView.js.map +1 -0
- package/lib/module/nativeAd/NativeAdViewComponents.js +179 -0
- package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -0
- package/lib/module/nativeAd/NativeAdViewProvider.js +23 -0
- package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -0
- package/lib/module/types/AdBannerViewProps.js +4 -0
- package/lib/module/types/AdBannerViewProps.js.map +1 -0
- package/lib/module/types/AdEvent.js +4 -0
- package/lib/module/types/AdEvent.js.map +1 -0
- package/lib/module/types/AdInfo.js +4 -0
- package/lib/module/types/AdInfo.js.map +1 -0
- package/lib/module/types/AdProps.js +4 -0
- package/lib/module/types/AdProps.js.map +1 -0
- package/lib/module/types/AppOpenAd.js +4 -0
- package/lib/module/types/AppOpenAd.js.map +1 -0
- package/lib/module/types/DaroMMobileAds.js +2 -0
- package/lib/module/types/DaroMMobileAds.js.map +1 -0
- package/lib/module/types/FullScreenAd.js +4 -0
- package/lib/module/types/FullScreenAd.js.map +1 -0
- package/lib/module/types/InterstitialAd.js +4 -0
- package/lib/module/types/InterstitialAd.js.map +1 -0
- package/lib/module/types/LightPopupAd.js +4 -0
- package/lib/module/types/LightPopupAd.js.map +1 -0
- package/lib/module/types/NativeAdViewProps.js +4 -0
- package/lib/module/types/NativeAdViewProps.js.map +1 -0
- package/lib/module/types/RewardedAd.js +4 -0
- package/lib/module/types/RewardedAd.js.map +1 -0
- package/lib/module/types/index.js +8 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/AdBannerView.d.ts +12 -0
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts +4 -0
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ErrorCode.d.ts +4 -0
- package/lib/typescript/commonjs/src/ErrorCode.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/EventEmitter.d.ts +4 -0
- package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts +4 -0
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts +4 -0
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/RewardedAd.d.ts +4 -0
- package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +11 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +6 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts +7 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +14 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +14 -0
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdEvent.d.ts +7 -0
- package/lib/typescript/commonjs/src/types/AdEvent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts +19 -0
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AdProps.d.ts +11 -0
- package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/AppOpenAd.d.ts +3 -0
- package/lib/typescript/commonjs/src/types/AppOpenAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts +6 -0
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/FullScreenAd.d.ts +21 -0
- package/lib/typescript/commonjs/src/types/FullScreenAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/InterstitialAd.d.ts +3 -0
- package/lib/typescript/commonjs/src/types/InterstitialAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/LightPopupAd.d.ts +18 -0
- package/lib/typescript/commonjs/src/types/LightPopupAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +17 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/RewardedAd.d.ts +9 -0
- package/lib/typescript/commonjs/src/types/RewardedAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/types/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/AdBannerView.d.ts +12 -0
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -0
- package/lib/typescript/module/src/AppOpenAd.d.ts +4 -0
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -0
- package/lib/typescript/module/src/ErrorCode.d.ts +4 -0
- package/lib/typescript/module/src/ErrorCode.d.ts.map +1 -0
- package/lib/typescript/module/src/EventEmitter.d.ts +4 -0
- package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -0
- package/lib/typescript/module/src/InterstitialAd.d.ts +4 -0
- package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -0
- package/lib/typescript/module/src/LightPopupAd.d.ts +4 -0
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -0
- package/lib/typescript/module/src/RewardedAd.d.ts +4 -0
- package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +11 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +6 -0
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -0
- package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts +7 -0
- package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -0
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +14 -0
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +14 -0
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdEvent.d.ts +7 -0
- package/lib/typescript/module/src/types/AdEvent.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdInfo.d.ts +19 -0
- package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AdProps.d.ts +11 -0
- package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -0
- package/lib/typescript/module/src/types/AppOpenAd.d.ts +3 -0
- package/lib/typescript/module/src/types/AppOpenAd.d.ts.map +1 -0
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts +6 -0
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +1 -0
- package/lib/typescript/module/src/types/FullScreenAd.d.ts +21 -0
- package/lib/typescript/module/src/types/FullScreenAd.d.ts.map +1 -0
- package/lib/typescript/module/src/types/InterstitialAd.d.ts +3 -0
- package/lib/typescript/module/src/types/InterstitialAd.d.ts.map +1 -0
- package/lib/typescript/module/src/types/LightPopupAd.d.ts +18 -0
- package/lib/typescript/module/src/types/LightPopupAd.d.ts.map +1 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +17 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -0
- package/lib/typescript/module/src/types/RewardedAd.d.ts +9 -0
- package/lib/typescript/module/src/types/RewardedAd.d.ts.map +1 -0
- package/lib/typescript/module/src/types/index.d.ts +6 -0
- package/lib/typescript/module/src/types/index.d.ts.map +1 -0
- package/package.json +185 -0
- package/react-native-daro-m.podspec +44 -0
- package/src/AdBannerView.tsx +138 -0
- package/src/AppOpenAd.ts +113 -0
- package/src/ErrorCode.ts +4 -0
- package/src/EventEmitter.ts +25 -0
- package/src/InterstitialAd.ts +113 -0
- package/src/LightPopupAd.ts +161 -0
- package/src/RewardedAd.ts +130 -0
- package/src/index.tsx +37 -0
- package/src/nativeAd/NativeAdView.tsx +124 -0
- package/src/nativeAd/NativeAdViewComponents.tsx +239 -0
- package/src/nativeAd/NativeAdViewProvider.tsx +32 -0
- package/src/types/AdBannerViewProps.ts +15 -0
- package/src/types/AdEvent.ts +9 -0
- package/src/types/AdInfo.ts +37 -0
- package/src/types/AdProps.ts +18 -0
- package/src/types/AppOpenAd.ts +3 -0
- package/src/types/DaroMMobileAds.ts +8 -0
- package/src/types/FullScreenAd.ts +28 -0
- package/src/types/InterstitialAd.ts +3 -0
- package/src/types/LightPopupAd.ts +19 -0
- package/src/types/NativeAdViewProps.ts +18 -0
- package/src/types/RewardedAd.ts +15 -0
- package/src/types/index.ts +5 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { NativeModules } from "react-native";
|
|
2
|
+
import { addEventListener, removeEventListener } from "./EventEmitter";
|
|
3
|
+
import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo, AdRewardInfo } from "./types/AdInfo";
|
|
4
|
+
import type { RewardedAdType } from "./types/RewardedAd";
|
|
5
|
+
|
|
6
|
+
const { DaroMModule } = NativeModules;
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
ON_REWARDED_AD_LOADED_EVENT,
|
|
10
|
+
ON_REWARDED_AD_LOAD_FAILED_EVENT,
|
|
11
|
+
ON_REWARDED_AD_CLICKED_EVENT,
|
|
12
|
+
ON_REWARDED_AD_DISPLAYED_EVENT,
|
|
13
|
+
ON_REWARDED_AD_FAILED_TO_DISPLAY_EVENT,
|
|
14
|
+
ON_REWARDED_AD_HIDDEN_EVENT,
|
|
15
|
+
ON_REWARDED_AD_RECEIVED_REWARD_EVENT,
|
|
16
|
+
ON_REWARDED_AD_IMPRESSION_RECORDED,
|
|
17
|
+
} = DaroMModule.getConstants();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const isAdReady = (adUnitId: string): Promise<boolean> => {
|
|
21
|
+
return DaroMModule.isRewardedAdReady(adUnitId);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const loadAd = (adUnitId: string): void => {
|
|
25
|
+
DaroMModule.loadRewardedAd(adUnitId);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const showAd = (adUnitId: string, customData?: string | null): void => {
|
|
29
|
+
DaroMModule.showRewardedAd(adUnitId, customData ?? null);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const addAdLoadedEventListener = (listener: (adInfo: AdInfo) => void): void => {
|
|
33
|
+
addEventListener(ON_REWARDED_AD_LOADED_EVENT, listener);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const removeAdLoadedEventListener = (): void => {
|
|
37
|
+
removeEventListener(ON_REWARDED_AD_LOADED_EVENT);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const addAdLoadFailedEventListener = (listener: (errorInfo: AdLoadFailedInfo) => void): void => {
|
|
41
|
+
addEventListener(ON_REWARDED_AD_LOAD_FAILED_EVENT, listener);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const removeAdLoadFailedEventListener = (): void => {
|
|
45
|
+
removeEventListener(ON_REWARDED_AD_LOAD_FAILED_EVENT);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const addAdClickedEventListener = (listener: (adInfo: AdInfo) => void): void => {
|
|
49
|
+
addEventListener(ON_REWARDED_AD_CLICKED_EVENT, listener);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const removeAdClickedEventListener = (): void => {
|
|
53
|
+
removeEventListener(ON_REWARDED_AD_CLICKED_EVENT);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const addAdDisplayedEventListener = (listener: (adInfo: AdInfo) => void): void => {
|
|
57
|
+
addEventListener(ON_REWARDED_AD_DISPLAYED_EVENT, listener);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const removeAdDisplayedEventListener = (): void => {
|
|
61
|
+
removeEventListener(ON_REWARDED_AD_DISPLAYED_EVENT);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const addAdFailedToDisplayEventListener = (listener: (errorInfo: AdDisplayFailedInfo) => void): void => {
|
|
65
|
+
addEventListener(ON_REWARDED_AD_FAILED_TO_DISPLAY_EVENT, listener);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const removeAdFailedToDisplayEventListener = (): void => {
|
|
69
|
+
removeEventListener(ON_REWARDED_AD_FAILED_TO_DISPLAY_EVENT);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const addAdHiddenEventListener = (listener: (adInfo: AdInfo) => void): void => {
|
|
73
|
+
addEventListener(ON_REWARDED_AD_HIDDEN_EVENT, listener);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const removeAdHiddenEventListener = (): void => {
|
|
77
|
+
removeEventListener(ON_REWARDED_AD_HIDDEN_EVENT);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const addAdImpressionRecordedListener = (listener: (adInfo: AdInfo) => void): void => {
|
|
81
|
+
addEventListener(ON_REWARDED_AD_IMPRESSION_RECORDED, listener);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const removeAdImpressionRecordedListener = (): void => {
|
|
85
|
+
removeEventListener(ON_REWARDED_AD_IMPRESSION_RECORDED);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Rewarded specific APIs
|
|
89
|
+
|
|
90
|
+
const addAdReceivedRewardEventListener = (listener: (adInfo: AdRewardInfo) => void): void => {
|
|
91
|
+
addEventListener(ON_REWARDED_AD_RECEIVED_REWARD_EVENT, listener);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const removeAdReceivedRewardEventListener = (): void => {
|
|
95
|
+
removeEventListener(ON_REWARDED_AD_RECEIVED_REWARD_EVENT);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
export const RewardedAd: RewardedAdType = {
|
|
100
|
+
isAdReady,
|
|
101
|
+
loadAd,
|
|
102
|
+
showAd,
|
|
103
|
+
|
|
104
|
+
addAdLoadedEventListener,
|
|
105
|
+
removeAdLoadedEventListener,
|
|
106
|
+
|
|
107
|
+
addAdLoadFailedEventListener,
|
|
108
|
+
removeAdLoadFailedEventListener,
|
|
109
|
+
|
|
110
|
+
addAdClickedEventListener,
|
|
111
|
+
removeAdClickedEventListener,
|
|
112
|
+
|
|
113
|
+
addAdDisplayedEventListener,
|
|
114
|
+
removeAdDisplayedEventListener,
|
|
115
|
+
|
|
116
|
+
addAdFailedToDisplayEventListener,
|
|
117
|
+
removeAdFailedToDisplayEventListener,
|
|
118
|
+
|
|
119
|
+
addAdHiddenEventListener,
|
|
120
|
+
removeAdHiddenEventListener,
|
|
121
|
+
|
|
122
|
+
addAdImpressionRecordedListener,
|
|
123
|
+
removeAdImpressionRecordedListener,
|
|
124
|
+
|
|
125
|
+
// Rewarded specific APIs
|
|
126
|
+
addAdReceivedRewardEventListener,
|
|
127
|
+
removeAdReceivedRewardEventListener,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default RewardedAd;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NativeModules,
|
|
3
|
+
Platform
|
|
4
|
+
} from 'react-native';
|
|
5
|
+
|
|
6
|
+
export * from './AdBannerView';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export { InterstitialAd } from './InterstitialAd';
|
|
9
|
+
export { RewardedAd } from './RewardedAd';
|
|
10
|
+
export { LightPopupAd } from './LightPopupAd';
|
|
11
|
+
|
|
12
|
+
export { NativeAdView } from './nativeAd/NativeAdView';
|
|
13
|
+
export { BodyView, CallToActionView, IconView, MediaView, TitleView } from './nativeAd/NativeAdViewComponents';
|
|
14
|
+
|
|
15
|
+
const LINKING_ERROR =
|
|
16
|
+
`The package 'react-native-daro-m' doesn't seem to be linked. Make sure: \n\n` +
|
|
17
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
18
|
+
'- You rebuilt the app after installing the package\n' +
|
|
19
|
+
'- You are not using Expo Go\n';
|
|
20
|
+
|
|
21
|
+
const DaroMModule = NativeModules.DaroMModule ? NativeModules.DaroMModule : new Proxy({}, {
|
|
22
|
+
get() {
|
|
23
|
+
throw new Error(LINKING_ERROR);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export async function initialize() {
|
|
28
|
+
await DaroMModule.initializeSdk();
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export async function showMediationDebugger() {
|
|
32
|
+
await DaroMModule.showMediationDebugger();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function setUserId(userId: String) {
|
|
36
|
+
await DaroMModule.setUserId(userId);
|
|
37
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
|
+
import { findNodeHandle, NativeModules, requireNativeComponent, UIManager, View, type ViewProps } from 'react-native';
|
|
3
|
+
import type { AdNativeEvent } from '../types/AdEvent';
|
|
4
|
+
import type { AdInfo, AdLoadFailedInfo } from '../types/AdInfo';
|
|
5
|
+
import type { NativeAdViewHandler, NativeAdViewProps } from '../types/NativeAdViewProps';
|
|
6
|
+
import { NativeAdViewContext, NativeAdViewProvider, type NativeAdViewContextType, type NativeAdViewType } from './NativeAdViewProvider';
|
|
7
|
+
|
|
8
|
+
const { DaroMModule } = NativeModules;
|
|
9
|
+
|
|
10
|
+
type NativeAdViewNativeEvents = {
|
|
11
|
+
onAdLoadedEvent(event: AdNativeEvent<AdInfo>): void;
|
|
12
|
+
onAdLoadFailedEvent(event: AdNativeEvent<AdLoadFailedInfo>): void;
|
|
13
|
+
onAdClickedEvent(event: AdNativeEvent<AdInfo>): void;
|
|
14
|
+
onAdImpressionRecordedEvent(event: AdNativeEvent<AdInfo>): void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ComponentName = 'DaroMNativeAdView';
|
|
18
|
+
const NativeAdViewComponent = requireNativeComponent<NativeAdViewProps & ViewProps & NativeAdViewNativeEvents>(ComponentName);
|
|
19
|
+
|
|
20
|
+
export const NativeAdView = forwardRef<NativeAdViewHandler, NativeAdViewProps & ViewProps>(function NativeAdView(props, ref) {
|
|
21
|
+
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const checkInitialization = async () => {
|
|
25
|
+
const result = await DaroMModule.isInitialized();
|
|
26
|
+
setIsInitialized(result);
|
|
27
|
+
if (!result) {
|
|
28
|
+
console.warn('NativeAdView is mounted before the initialization of the DaroM React Native module.');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
checkInitialization();
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
// Avoid rendering the NativeAdView if the SDK is not initialized
|
|
36
|
+
if (!isInitialized) {
|
|
37
|
+
return <View {...props} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<NativeAdViewProvider>
|
|
42
|
+
<NativeAdViewImpl {...props} ref={ref} />
|
|
43
|
+
</NativeAdViewProvider>
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const NativeAdViewImpl = forwardRef<NativeAdViewHandler, NativeAdViewProps & ViewProps>(function NativeAdViewImpl(
|
|
48
|
+
{ adUnitId, onAdLoaded, onAdLoadFailed, onAdClicked, onAdImpressionRecorded, children, style, loadOnMount = true, ...otherProps },
|
|
49
|
+
ref
|
|
50
|
+
) {
|
|
51
|
+
// Context provides functions to manage native ad and native ad view state
|
|
52
|
+
const { setNativeAdView } = useContext(NativeAdViewContext) as NativeAdViewContextType;
|
|
53
|
+
|
|
54
|
+
const nativeAdViewRef = useRef<NativeAdViewType | null>(null);
|
|
55
|
+
|
|
56
|
+
// Load a new ad
|
|
57
|
+
const loadAd = useCallback(() => {
|
|
58
|
+
if (nativeAdViewRef.current) {
|
|
59
|
+
UIManager.dispatchViewManagerCommand(
|
|
60
|
+
findNodeHandle(nativeAdViewRef.current),
|
|
61
|
+
// @ts-ignore: Issue in RN ts defs
|
|
62
|
+
UIManager.getViewManagerConfig(ComponentName).Commands.loadAd,
|
|
63
|
+
[],
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
useImperativeHandle(ref, () => ({ loadAd }), [loadAd]);
|
|
69
|
+
|
|
70
|
+
// Save the DOM element reference
|
|
71
|
+
const saveElement = useCallback(
|
|
72
|
+
(element: NativeAdViewType | null) => {
|
|
73
|
+
if (element) {
|
|
74
|
+
nativeAdViewRef.current = element;
|
|
75
|
+
setNativeAdView(element);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
[setNativeAdView]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const onAdLoadedEvent = useCallback(
|
|
82
|
+
(event: AdNativeEvent<AdInfo>) => {
|
|
83
|
+
onAdLoaded?.(event.nativeEvent);
|
|
84
|
+
},
|
|
85
|
+
[onAdLoaded]
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const onAdLoadFailedEvent = useCallback(
|
|
89
|
+
(event: AdNativeEvent<AdLoadFailedInfo>) => {
|
|
90
|
+
onAdLoadFailed?.(event.nativeEvent);
|
|
91
|
+
},
|
|
92
|
+
[onAdLoadFailed]
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const onAdClickedEvent = useCallback(
|
|
96
|
+
(event: AdNativeEvent<AdInfo>) => {
|
|
97
|
+
onAdClicked?.(event.nativeEvent);
|
|
98
|
+
},
|
|
99
|
+
[onAdClicked]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const onAdImpressionRecordedEvent = useCallback(
|
|
103
|
+
(event: AdNativeEvent<AdInfo>) => {
|
|
104
|
+
onAdImpressionRecorded?.(event.nativeEvent);
|
|
105
|
+
},
|
|
106
|
+
[onAdImpressionRecorded]
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<NativeAdViewComponent
|
|
111
|
+
ref={saveElement}
|
|
112
|
+
adUnitId={adUnitId}
|
|
113
|
+
loadOnMount={loadOnMount}
|
|
114
|
+
onAdLoadedEvent={onAdLoadedEvent}
|
|
115
|
+
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
116
|
+
onAdClickedEvent={onAdClickedEvent}
|
|
117
|
+
onAdImpressionRecordedEvent={onAdImpressionRecordedEvent}
|
|
118
|
+
style={style}
|
|
119
|
+
{...otherProps}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</NativeAdViewComponent>
|
|
123
|
+
);
|
|
124
|
+
});
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import type { ImageProps, StyleProp, TextProps, TextStyle, ImageStyle, ViewProps } from 'react-native';
|
|
4
|
+
import { findNodeHandle, Image, Platform, Text, View } from 'react-native';
|
|
5
|
+
import { NativeAdViewContext } from './NativeAdViewProvider';
|
|
6
|
+
|
|
7
|
+
// 스타일 속성 추출을 위한 타입 정의
|
|
8
|
+
type StyleProps = {
|
|
9
|
+
fontSize?: number;
|
|
10
|
+
fontWeight?: string;
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
color?: string;
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
textAlign?: 'auto' | 'left' | 'right' | 'center' | 'justify';
|
|
15
|
+
numberOfLines?: number;
|
|
16
|
+
lineBreakMode?: 'head' | 'middle' | 'tail' | 'clip' | 'word-wrap';
|
|
17
|
+
opacity?: number;
|
|
18
|
+
display?: 'none' | 'flex';
|
|
19
|
+
isEnabled?: boolean;
|
|
20
|
+
clipsToBounds?: boolean;
|
|
21
|
+
borderRadius?: number;
|
|
22
|
+
borderWidth?: number;
|
|
23
|
+
borderColor?: string;
|
|
24
|
+
shadowColor?: string;
|
|
25
|
+
shadowOffset?: { width: number; height: number };
|
|
26
|
+
shadowOpacity?: number;
|
|
27
|
+
shadowRadius?: number;
|
|
28
|
+
padding?: number;
|
|
29
|
+
margin?: number;
|
|
30
|
+
paddingTop?: number;
|
|
31
|
+
paddingRight?: number;
|
|
32
|
+
paddingBottom?: number;
|
|
33
|
+
paddingLeft?: number;
|
|
34
|
+
marginTop?: number;
|
|
35
|
+
marginRight?: number;
|
|
36
|
+
marginBottom?: number;
|
|
37
|
+
marginLeft?: number;
|
|
38
|
+
position?: 'absolute' | 'relative';
|
|
39
|
+
top?: number;
|
|
40
|
+
right?: number;
|
|
41
|
+
bottom?: number;
|
|
42
|
+
left?: number;
|
|
43
|
+
width?: number | string;
|
|
44
|
+
height?: number | string;
|
|
45
|
+
transform?: any[];
|
|
46
|
+
scale?: number;
|
|
47
|
+
rotate?: string;
|
|
48
|
+
translateX?: number;
|
|
49
|
+
translateY?: number;
|
|
50
|
+
zIndex?: number;
|
|
51
|
+
overflow?: 'visible' | 'hidden' | 'scroll';
|
|
52
|
+
backfaceVisibility?: 'visible' | 'hidden';
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// 스타일 속성 추출 커스텀 훅
|
|
56
|
+
const useStyleProps = (style: StyleProp<TextStyle>): StyleProps => {
|
|
57
|
+
return useMemo(() => {
|
|
58
|
+
const styleObj = style as TextStyle;
|
|
59
|
+
return {
|
|
60
|
+
// 1. 폰트 관련
|
|
61
|
+
fontSize: styleObj.fontSize as number,
|
|
62
|
+
fontWeight: styleObj.fontWeight as string,
|
|
63
|
+
fontFamily: styleObj.fontFamily as string,
|
|
64
|
+
color: styleObj.color as string,
|
|
65
|
+
|
|
66
|
+
// 2. 배경색
|
|
67
|
+
backgroundColor: styleObj.backgroundColor as string,
|
|
68
|
+
|
|
69
|
+
// 3. 정렬
|
|
70
|
+
textAlign: styleObj.textAlign as 'auto' | 'left' | 'right' | 'center' | 'justify',
|
|
71
|
+
|
|
72
|
+
// 6. 투명도
|
|
73
|
+
opacity: styleObj.opacity as number,
|
|
74
|
+
|
|
75
|
+
// 7. 숨김
|
|
76
|
+
display: styleObj.display as 'none' | 'flex',
|
|
77
|
+
|
|
78
|
+
// 10. 모서리 둥글게
|
|
79
|
+
borderRadius: styleObj.borderRadius as number,
|
|
80
|
+
|
|
81
|
+
// 11. 테두리
|
|
82
|
+
borderWidth: styleObj.borderWidth as number,
|
|
83
|
+
borderColor: styleObj.borderColor as string,
|
|
84
|
+
|
|
85
|
+
// 12. 그림자
|
|
86
|
+
shadowColor: styleObj.shadowColor as string,
|
|
87
|
+
shadowOffset: styleObj.shadowOffset as { width: number; height: number },
|
|
88
|
+
shadowOpacity: styleObj.shadowOpacity as number,
|
|
89
|
+
shadowRadius: styleObj.shadowRadius as number,
|
|
90
|
+
|
|
91
|
+
// 13. 여백
|
|
92
|
+
padding: styleObj.padding as number,
|
|
93
|
+
margin: styleObj.margin as number,
|
|
94
|
+
paddingTop: styleObj.paddingTop as number,
|
|
95
|
+
paddingRight: styleObj.paddingRight as number,
|
|
96
|
+
paddingBottom: styleObj.paddingBottom as number,
|
|
97
|
+
paddingLeft: styleObj.paddingLeft as number,
|
|
98
|
+
marginTop: styleObj.marginTop as number,
|
|
99
|
+
marginRight: styleObj.marginRight as number,
|
|
100
|
+
marginBottom: styleObj.marginBottom as number,
|
|
101
|
+
marginLeft: styleObj.marginLeft as number,
|
|
102
|
+
|
|
103
|
+
// 14. 위치
|
|
104
|
+
position: styleObj.position as 'absolute' | 'relative',
|
|
105
|
+
top: styleObj.top as number,
|
|
106
|
+
right: styleObj.right as number,
|
|
107
|
+
bottom: styleObj.bottom as number,
|
|
108
|
+
left: styleObj.left as number,
|
|
109
|
+
|
|
110
|
+
// 15. 크기
|
|
111
|
+
width: styleObj.width as number,
|
|
112
|
+
height: styleObj.height as number,
|
|
113
|
+
|
|
114
|
+
// 16. 변환
|
|
115
|
+
transform: styleObj.transform as any[],
|
|
116
|
+
|
|
117
|
+
// 17. 기타
|
|
118
|
+
zIndex: styleObj.zIndex as number,
|
|
119
|
+
overflow: styleObj.overflow as 'visible' | 'hidden' | 'scroll',
|
|
120
|
+
backfaceVisibility: styleObj.backfaceVisibility as 'visible' | 'hidden',
|
|
121
|
+
};
|
|
122
|
+
}, [style]);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Image 스타일 속성을 위한 타입 정의 추가
|
|
126
|
+
type ImageStyleProps = StyleProps & {
|
|
127
|
+
resizeMode?: 'cover' | 'contain' | 'stretch' | 'repeat' | 'center';
|
|
128
|
+
tintColor?: string;
|
|
129
|
+
overlayColor?: string;
|
|
130
|
+
borderRadius?: number;
|
|
131
|
+
borderTopLeftRadius?: number;
|
|
132
|
+
borderTopRightRadius?: number;
|
|
133
|
+
borderBottomLeftRadius?: number;
|
|
134
|
+
borderBottomRightRadius?: number;
|
|
135
|
+
aspectRatio?: number;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Image 스타일 속성 추출 커스텀 훅
|
|
139
|
+
const useImageStyleProps = (style: StyleProp<ImageStyle>): ImageStyleProps => {
|
|
140
|
+
return useMemo(() => {
|
|
141
|
+
const styleObj = style as ImageStyle;
|
|
142
|
+
return {
|
|
143
|
+
// 기본 스타일 속성
|
|
144
|
+
backgroundColor: styleObj.backgroundColor as string,
|
|
145
|
+
borderRadius: styleObj.borderRadius as number,
|
|
146
|
+
borderWidth: styleObj.borderWidth as number,
|
|
147
|
+
borderColor: styleObj.borderColor as string,
|
|
148
|
+
|
|
149
|
+
shadowColor: styleObj.shadowColor as string,
|
|
150
|
+
shadowOffset: styleObj.shadowOffset as { width: number; height: number },
|
|
151
|
+
shadowOpacity: styleObj.shadowOpacity as number,
|
|
152
|
+
shadowRadius: styleObj.shadowRadius as number,
|
|
153
|
+
|
|
154
|
+
width: styleObj.width as number,
|
|
155
|
+
height: styleObj.height as number,
|
|
156
|
+
|
|
157
|
+
// Image 전용 스타일 속성
|
|
158
|
+
resizeMode: styleObj.resizeMode as 'cover' | 'contain' | 'stretch' | 'repeat' | 'center',
|
|
159
|
+
tintColor: styleObj.tintColor as string,
|
|
160
|
+
overlayColor: styleObj.overlayColor as string,
|
|
161
|
+
aspectRatio: styleObj.aspectRatio as number,
|
|
162
|
+
};
|
|
163
|
+
}, [style]);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// 네이티브 뷰 속성 설정 커스텀 훅
|
|
167
|
+
const useNativeAdViewProps = (ref: React.RefObject<any>, nativePropKey: string, styleProps?: StyleProps) => {
|
|
168
|
+
const { nativeAdView } = useContext(NativeAdViewContext);
|
|
169
|
+
|
|
170
|
+
const setNativeProps = useCallback(() => {
|
|
171
|
+
if (!ref.current) return;
|
|
172
|
+
const props: any = {
|
|
173
|
+
[nativePropKey]: findNodeHandle(ref.current),
|
|
174
|
+
};
|
|
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]);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// 공통 Text 컴포넌트
|
|
189
|
+
const AdTextView = (props: TextProps & { nativePropKey: string }) => {
|
|
190
|
+
const { nativePropKey, ...restProps } = props;
|
|
191
|
+
const textRef = useRef<Text | null>(null);
|
|
192
|
+
const styleProps = useStyleProps(props.style);
|
|
193
|
+
|
|
194
|
+
useNativeAdViewProps(textRef, nativePropKey, styleProps);
|
|
195
|
+
|
|
196
|
+
return <Text {...restProps} ref={textRef} />;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const TitleView = (props: TextProps) => {
|
|
200
|
+
return <AdTextView {...props} nativePropKey="titleView" />;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export const BodyView = (props: TextProps) => {
|
|
204
|
+
return <AdTextView {...props} nativePropKey="bodyView" />;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export const CallToActionView = (props: TextProps) => {
|
|
208
|
+
const callToActionRef = useRef<Text | null>(null);
|
|
209
|
+
const styleProps = useStyleProps(props.style);
|
|
210
|
+
|
|
211
|
+
useNativeAdViewProps(callToActionRef, 'callToActionView', styleProps);
|
|
212
|
+
|
|
213
|
+
// TouchableOpacity disables clicking on certain Android devices.
|
|
214
|
+
if (Platform.OS === 'android') {
|
|
215
|
+
return <Text {...props} ref={callToActionRef} />;
|
|
216
|
+
} else {
|
|
217
|
+
return (
|
|
218
|
+
<View>
|
|
219
|
+
<Text {...props} ref={callToActionRef} />
|
|
220
|
+
</View>
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export const IconView = (props: Omit<ImageProps, 'source'>) => {
|
|
226
|
+
const imageRef = useRef<Image | null>(null);
|
|
227
|
+
const iconViewStyleProps = useImageStyleProps(props.style);
|
|
228
|
+
useNativeAdViewProps(imageRef, 'iconView', iconViewStyleProps);
|
|
229
|
+
|
|
230
|
+
return <Image {...props} ref={imageRef} source={0} />;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export const MediaView = (props: ViewProps) => {
|
|
234
|
+
const viewRef = useRef<View | null>(null);
|
|
235
|
+
useNativeAdViewProps(viewRef, 'mediaView');
|
|
236
|
+
|
|
237
|
+
return <View {...props} ref={viewRef} />;
|
|
238
|
+
};
|
|
239
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
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';
|
|
6
|
+
|
|
7
|
+
export type NativeAdViewType = React.Component<NativeAdViewProps> & NativeMethods;
|
|
8
|
+
|
|
9
|
+
export type NativeAdViewContextType = {
|
|
10
|
+
nativeAdView: NativeAdViewType | null;
|
|
11
|
+
setNativeAdView: React.Dispatch<React.SetStateAction<NativeAdViewType | null>>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const NativeAdViewContext = createContext<NativeAdViewContextType>({
|
|
16
|
+
nativeAdView: null,
|
|
17
|
+
setNativeAdView: () => { },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const NativeAdViewProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
|
|
21
|
+
const [nativeAdView, setNativeAdView] = useState<NativeAdViewType | null>(null);
|
|
22
|
+
|
|
23
|
+
const providerValue = React.useMemo(
|
|
24
|
+
() => ({
|
|
25
|
+
nativeAdView,
|
|
26
|
+
setNativeAdView,
|
|
27
|
+
}),
|
|
28
|
+
[nativeAdView]
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return <NativeAdViewContext.Provider value={providerValue}>{children}</NativeAdViewContext.Provider>;
|
|
32
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AdFormat } from "../AdBannerView";
|
|
2
|
+
import type { AdProps } from "./AdProps";
|
|
3
|
+
|
|
4
|
+
export type AdBannerViewHandler = {
|
|
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
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AdBannerViewProps = AdProps & {
|
|
12
|
+
color?: string;
|
|
13
|
+
adFormat: AdFormat;
|
|
14
|
+
loadOnMount?: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AdInfo, AdLoadFailedInfo, AdDisplayFailedInfo, AdRewardInfo } from './AdInfo';
|
|
2
|
+
|
|
3
|
+
export type AdEventObject = AdInfo | AdLoadFailedInfo | AdDisplayFailedInfo | AdRewardInfo;
|
|
4
|
+
|
|
5
|
+
// Defines a generic event listener for the pragrammatic methods to receive an event from the native module.
|
|
6
|
+
export type AdEventListener<T extends AdEventObject> = (event: T) => void;
|
|
7
|
+
|
|
8
|
+
// Defines a generic event object for the UI components i.e. AdView and NativeAdView to receive an event from the native module.
|
|
9
|
+
export type AdNativeEvent<T extends AdEventObject> = { nativeEvent: T };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ErrorCode } from '../ErrorCode';
|
|
2
|
+
|
|
3
|
+
// Represents an ad
|
|
4
|
+
export type AdInfo = {
|
|
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
|
+
};
|
|
10
|
+
|
|
11
|
+
// Encapsulates various data for MAX load errors.
|
|
12
|
+
export type AdLoadFailedInfo = {
|
|
13
|
+
// The ad unit ID for which this ad was loaded.
|
|
14
|
+
adUnitId: string;
|
|
15
|
+
|
|
16
|
+
// The error code for the error.
|
|
17
|
+
code: ErrorCode;
|
|
18
|
+
|
|
19
|
+
message: string;
|
|
20
|
+
|
|
21
|
+
// The total latency in milliseconds for this waterfall to finish processing.
|
|
22
|
+
latencyMillis: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Encapsulates various data for MAX display errors.
|
|
26
|
+
export type AdDisplayFailedInfo = {
|
|
27
|
+
message: string | null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Represents a reward given to the user.
|
|
31
|
+
export type AdRewardInfo = {
|
|
32
|
+
// The reward label.
|
|
33
|
+
rewardLabel?: string | null;
|
|
34
|
+
|
|
35
|
+
// The rewarded amount.
|
|
36
|
+
rewardAmount: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AdLoadFailedInfo } from "./AdInfo";
|
|
2
|
+
|
|
3
|
+
import type { AdInfo } from "./AdInfo";
|
|
4
|
+
|
|
5
|
+
export type AdProps = {
|
|
6
|
+
|
|
7
|
+
adUnitId: string;
|
|
8
|
+
|
|
9
|
+
placement?: string | null;
|
|
10
|
+
|
|
11
|
+
onAdLoaded?: (adInfo: AdInfo) => void;
|
|
12
|
+
|
|
13
|
+
onAdLoadFailed?: (error: AdLoadFailedInfo) => void;
|
|
14
|
+
|
|
15
|
+
onAdClicked?: (adInfo: AdInfo) => void;
|
|
16
|
+
|
|
17
|
+
onAdImpressionRecorded?: (adInfo: AdInfo) => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AdDisplayFailedInfo, AdInfo, AdLoadFailedInfo } from "./AdInfo";
|
|
2
|
+
|
|
3
|
+
export type FullScreenAdType = {
|
|
4
|
+
isAdReady: (adUnitId: string) => Promise<boolean>;
|
|
5
|
+
loadAd: (adUnitId: string) => void;
|
|
6
|
+
showAd: (adUnitId: string) => void;
|
|
7
|
+
|
|
8
|
+
addAdLoadedEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
9
|
+
removeAdLoadedEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
10
|
+
|
|
11
|
+
addAdLoadFailedEventListener: (listener: (errorInfo: AdLoadFailedInfo) => void) => void;
|
|
12
|
+
removeAdLoadFailedEventListener: (listener: (errorInfo: AdLoadFailedInfo) => void) => void;
|
|
13
|
+
|
|
14
|
+
addAdClickedEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
15
|
+
removeAdClickedEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
16
|
+
|
|
17
|
+
addAdDisplayedEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
18
|
+
removeAdDisplayedEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
19
|
+
|
|
20
|
+
addAdFailedToDisplayEventListener: (listener: (errorInfo: AdDisplayFailedInfo) => void) => void;
|
|
21
|
+
removeAdFailedToDisplayEventListener: (listener: (errorInfo: AdDisplayFailedInfo) => void) => void;
|
|
22
|
+
|
|
23
|
+
addAdHiddenEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
24
|
+
removeAdHiddenEventListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
25
|
+
|
|
26
|
+
addAdImpressionRecordedListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
27
|
+
removeAdImpressionRecordedListener: (listener: (adInfo: AdInfo) => void) => void;
|
|
28
|
+
};
|