react-native-daro 1.0.15 → 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/android/build.gradle +11 -1
- package/android/src/main/java/com/daro/reactnative/DaroMAdBannerViewManager.kt +34 -11
- package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +79 -48
- package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +80 -25
- package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +28 -4
- package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
- package/android/src/main/java/com/daro/reactnative/event/DaroMEvent.kt +18 -7
- package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +18 -5
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +301 -52
- 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/ios/DaroMModule+AppOpen.swift +13 -10
- package/ios/DaroMModule+Interstitial.swift +12 -9
- package/ios/DaroMModule+LightPopup.swift +16 -13
- package/ios/DaroMModule+Rewarded.swift +12 -9
- package/ios/DaroMModule.mm +45 -17
- package/ios/DaroMModule.swift +4 -4
- 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/DaroMediationTypes.swift +1 -0
- package/lib/commonjs/AdBannerView.js +20 -39
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +43 -10
- 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/EventEmitter.js +4 -5
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/InterstitialAd.js +9 -11
- package/lib/commonjs/InterstitialAd.js.map +1 -1
- package/lib/commonjs/LightPopupAd.js +11 -12
- 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 +9 -11
- 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 -22
- 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/module/AdBannerView.js +19 -40
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +43 -11
- 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/EventEmitter.js +4 -6
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/InterstitialAd.js +8 -11
- package/lib/module/InterstitialAd.js.map +1 -1
- package/lib/module/LightPopupAd.js +11 -13
- 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 +8 -11
- 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 -23
- 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/typescript/commonjs/plugin/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AdBannerView.d.ts +2 -2
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- 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/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
- 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.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 +1 -0
- 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/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 +1 -1
- package/lib/typescript/module/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/module/src/AdBannerView.d.ts +2 -2
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- 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/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
- 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.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 +1 -0
- 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/NativeAdViewProps.d.ts +2 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +12 -5
- package/plugin/build/index.d.ts +1 -1
- package/plugin/build/withAndroid.js +99 -17
- package/plugin/build/withIos.js +4 -5
- package/react-native-daro.podspec +3 -0
- package/src/AdBannerView.tsx +24 -61
- package/src/AppOpenAd.ts +46 -9
- package/src/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/src/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/src/DaroMediaViewNativeComponent.ts +9 -0
- package/src/EventEmitter.ts +4 -5
- package/src/InterstitialAd.ts +8 -10
- package/src/LightPopupAd.ts +11 -12
- package/src/NativeDaroModule.ts +91 -0
- package/src/RewardedAd.ts +8 -10
- 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 +41 -54
- package/src/nativeAd/NativeAdViewComponents.tsx +80 -42
- package/src/nativeAd/NativeAdViewProvider.tsx +75 -17
- package/src/types/NativeAdViewProps.ts +7 -0
- package/ios/DaroMAdBannerViewManager.swift +0 -91
- package/ios/DaroMNativeAdViewManager.swift +0 -291
package/src/InterstitialAd.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
1
|
import {
|
|
3
2
|
addEventListener,
|
|
4
3
|
removeEventListener,
|
|
5
4
|
AdEventEmitter,
|
|
6
5
|
} from './EventEmitter';
|
|
6
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
7
7
|
import type {
|
|
8
8
|
AdDisplayFailedInfo,
|
|
9
9
|
AdInfo,
|
|
@@ -11,8 +11,6 @@ import type {
|
|
|
11
11
|
} from './types/AdInfo';
|
|
12
12
|
import { AdEventType, type AdEventPayloadMap } from './types/AdEvent';
|
|
13
13
|
|
|
14
|
-
const { DaroMModule } = NativeModules;
|
|
15
|
-
|
|
16
14
|
const {
|
|
17
15
|
ON_INTERSTITIAL_LOADED_EVENT,
|
|
18
16
|
ON_INTERSTITIAL_LOAD_FAILED_EVENT,
|
|
@@ -21,7 +19,7 @@ const {
|
|
|
21
19
|
ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT,
|
|
22
20
|
ON_INTERSTITIAL_HIDDEN_EVENT,
|
|
23
21
|
ON_INTERSTITIAL_AD_IMPRESSION_RECORDED,
|
|
24
|
-
} =
|
|
22
|
+
} = NativeDaroModule.getConstants();
|
|
25
23
|
|
|
26
24
|
const NATIVE_EVENT_BY_TYPE: Record<AdEventType, string> = {
|
|
27
25
|
[AdEventType.LOADED]: ON_INTERSTITIAL_LOADED_EVENT,
|
|
@@ -51,15 +49,15 @@ export class InterstitialAd {
|
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
isAdReady(): Promise<boolean> {
|
|
54
|
-
return
|
|
52
|
+
return NativeDaroModule.isInterstitialReady(this.requestId, this.adUnitId);
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
load(): void {
|
|
58
|
-
|
|
56
|
+
NativeDaroModule.loadInterstitial(this.requestId, this.adUnitId);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
show(): void {
|
|
62
|
-
|
|
60
|
+
NativeDaroModule.showInterstitial(this.requestId, this.adUnitId);
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
addAdEventListener<T extends AdEventType>(
|
|
@@ -109,19 +107,19 @@ export class InterstitialAd {
|
|
|
109
107
|
/** @deprecated `InterstitialAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
|
|
110
108
|
static isAdReady(adUnitId: string): Promise<boolean> {
|
|
111
109
|
const requestId = InterstitialAd._getLegacyRequestId(adUnitId);
|
|
112
|
-
return
|
|
110
|
+
return NativeDaroModule.isInterstitialReady(requestId, adUnitId);
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
/** @deprecated `InterstitialAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
|
|
116
114
|
static loadAd(adUnitId: string): void {
|
|
117
115
|
const requestId = InterstitialAd._getLegacyRequestId(adUnitId);
|
|
118
|
-
|
|
116
|
+
NativeDaroModule.loadInterstitial(requestId, adUnitId);
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
/** @deprecated `InterstitialAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
|
|
122
120
|
static showAd(adUnitId: string): void {
|
|
123
121
|
const requestId = InterstitialAd._getLegacyRequestId(adUnitId);
|
|
124
|
-
|
|
122
|
+
NativeDaroModule.showInterstitial(requestId, adUnitId);
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
/** @deprecated `addAdEventListener(AdEventType.LOADED, ...)`를 인스턴스에서 사용하세요. */
|
package/src/LightPopupAd.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { processColor, type ColorValue } 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,
|
|
@@ -12,8 +13,6 @@ import type {
|
|
|
12
13
|
import type { LightPopupAdConfiguration } from './types/LightPopupAd';
|
|
13
14
|
import { AdEventType, type AdEventPayloadMap } from './types/AdEvent';
|
|
14
15
|
|
|
15
|
-
const { DaroMModule } = NativeModules;
|
|
16
|
-
|
|
17
16
|
const {
|
|
18
17
|
ON_LIGHTPOPUP_LOADED_EVENT,
|
|
19
18
|
ON_LIGHTPOPUP_LOAD_FAILED_EVENT,
|
|
@@ -22,7 +21,7 @@ const {
|
|
|
22
21
|
ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT,
|
|
23
22
|
ON_LIGHTPOPUP_HIDDEN_EVENT,
|
|
24
23
|
ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED,
|
|
25
|
-
} =
|
|
24
|
+
} = NativeDaroModule.getConstants();
|
|
26
25
|
|
|
27
26
|
const NATIVE_EVENT_BY_TYPE: Record<AdEventType, string> = {
|
|
28
27
|
[AdEventType.LOADED]: ON_LIGHTPOPUP_LOADED_EVENT,
|
|
@@ -103,19 +102,19 @@ export class LightPopupAd {
|
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
isAdReady(): Promise<boolean> {
|
|
106
|
-
return
|
|
105
|
+
return NativeDaroModule.isLightPopupReady(this.requestId, this.adUnitId);
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
load(): void {
|
|
110
|
-
|
|
109
|
+
NativeDaroModule.loadLightPopup(this.requestId, this.adUnitId);
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
show(): void {
|
|
114
|
-
|
|
113
|
+
NativeDaroModule.showLightPopup(this.requestId, this.adUnitId);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
setConfiguration(configuration: LightPopupAdConfiguration): void {
|
|
118
|
-
|
|
117
|
+
NativeDaroModule.setLightPopupAdConfiguration(
|
|
119
118
|
this.requestId,
|
|
120
119
|
this.adUnitId,
|
|
121
120
|
normalizeConfiguration(configuration)
|
|
@@ -167,19 +166,19 @@ export class LightPopupAd {
|
|
|
167
166
|
/** @deprecated `LightPopupAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
|
|
168
167
|
static isAdReady(adUnitId: string): Promise<boolean> {
|
|
169
168
|
const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
|
|
170
|
-
return
|
|
169
|
+
return NativeDaroModule.isLightPopupReady(requestId, adUnitId);
|
|
171
170
|
}
|
|
172
171
|
|
|
173
172
|
/** @deprecated `LightPopupAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
|
|
174
173
|
static loadAd(adUnitId: string): void {
|
|
175
174
|
const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
|
|
176
|
-
|
|
175
|
+
NativeDaroModule.loadLightPopup(requestId, adUnitId);
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
/** @deprecated `LightPopupAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
|
|
180
179
|
static showAd(adUnitId: string): void {
|
|
181
180
|
const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
|
|
182
|
-
|
|
181
|
+
NativeDaroModule.showLightPopup(requestId, adUnitId);
|
|
183
182
|
}
|
|
184
183
|
|
|
185
184
|
/** @deprecated 인스턴스의 `setConfiguration()`을 사용하세요. */
|
|
@@ -188,7 +187,7 @@ export class LightPopupAd {
|
|
|
188
187
|
configuration: LightPopupAdConfiguration
|
|
189
188
|
): void {
|
|
190
189
|
const requestId = LightPopupAd._getLegacyRequestId(adUnitId);
|
|
191
|
-
|
|
190
|
+
NativeDaroModule.setLightPopupAdConfiguration(
|
|
192
191
|
requestId,
|
|
193
192
|
adUnitId,
|
|
194
193
|
normalizeConfiguration(configuration)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
UnsafeObject,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export type DaroModuleConstants = {
|
|
9
|
+
ON_INTERSTITIAL_LOADED_EVENT: string;
|
|
10
|
+
ON_INTERSTITIAL_LOAD_FAILED_EVENT: string;
|
|
11
|
+
ON_INTERSTITIAL_CLICKED_EVENT: string;
|
|
12
|
+
ON_INTERSTITIAL_DISPLAYED_EVENT: string;
|
|
13
|
+
ON_INTERSTITIAL_AD_FAILED_TO_DISPLAY_EVENT: string;
|
|
14
|
+
ON_INTERSTITIAL_HIDDEN_EVENT: string;
|
|
15
|
+
ON_INTERSTITIAL_AD_IMPRESSION_RECORDED: string;
|
|
16
|
+
|
|
17
|
+
ON_REWARDED_AD_LOADED_EVENT: string;
|
|
18
|
+
ON_REWARDED_AD_LOAD_FAILED_EVENT: string;
|
|
19
|
+
ON_REWARDED_AD_CLICKED_EVENT: string;
|
|
20
|
+
ON_REWARDED_AD_DISPLAYED_EVENT: string;
|
|
21
|
+
ON_REWARDED_AD_FAILED_TO_DISPLAY_EVENT: string;
|
|
22
|
+
ON_REWARDED_AD_HIDDEN_EVENT: string;
|
|
23
|
+
ON_REWARDED_AD_RECEIVED_REWARD_EVENT: string;
|
|
24
|
+
ON_REWARDED_AD_IMPRESSION_RECORDED: string;
|
|
25
|
+
|
|
26
|
+
ON_APPOPEN_AD_LOADED_EVENT: string;
|
|
27
|
+
ON_APPOPEN_AD_LOAD_FAILED_EVENT: string;
|
|
28
|
+
ON_APPOPEN_AD_CLICKED_EVENT: string;
|
|
29
|
+
ON_APPOPEN_AD_DISPLAYED_EVENT: string;
|
|
30
|
+
ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT: string;
|
|
31
|
+
ON_APPOPEN_AD_HIDDEN_EVENT: string;
|
|
32
|
+
ON_APPOPEN_AD_IMPRESSION_RECORDED: string;
|
|
33
|
+
|
|
34
|
+
ON_LIGHTPOPUP_LOADED_EVENT: string;
|
|
35
|
+
ON_LIGHTPOPUP_LOAD_FAILED_EVENT: string;
|
|
36
|
+
ON_LIGHTPOPUP_CLICKED_EVENT: string;
|
|
37
|
+
ON_LIGHTPOPUP_DISPLAYED_EVENT: string;
|
|
38
|
+
ON_LIGHTPOPUP_AD_FAILED_TO_DISPLAY_EVENT: string;
|
|
39
|
+
ON_LIGHTPOPUP_HIDDEN_EVENT: string;
|
|
40
|
+
ON_LIGHTPOPUP_AD_IMPRESSION_RECORDED: string;
|
|
41
|
+
|
|
42
|
+
BANNER_AD_FORMAT_LABEL: string;
|
|
43
|
+
MREC_AD_FORMAT_LABEL: string;
|
|
44
|
+
UNKNOWN_AD_FORMAT_LABEL?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export interface Spec extends TurboModule {
|
|
48
|
+
getConstants: () => DaroModuleConstants;
|
|
49
|
+
addListener: (eventName: string) => void;
|
|
50
|
+
removeListeners: (count: number) => void;
|
|
51
|
+
|
|
52
|
+
isInitialized: () => Promise<boolean>;
|
|
53
|
+
initializeSdk: () => Promise<void>;
|
|
54
|
+
setUserId: (userId: string) => Promise<void>;
|
|
55
|
+
showMediationDebugger: () => Promise<void>;
|
|
56
|
+
|
|
57
|
+
isInterstitialReady: (
|
|
58
|
+
requestId: Double,
|
|
59
|
+
adUnitId: string
|
|
60
|
+
) => Promise<boolean>;
|
|
61
|
+
loadInterstitial: (requestId: Double, adUnitId: string) => Promise<void>;
|
|
62
|
+
showInterstitial: (requestId: Double, adUnitId: string) => Promise<void>;
|
|
63
|
+
|
|
64
|
+
isRewardedAdReady: (requestId: Double, adUnitId: string) => Promise<boolean>;
|
|
65
|
+
loadRewardedAd: (requestId: Double, adUnitId: string) => Promise<void>;
|
|
66
|
+
showRewardedAd: (
|
|
67
|
+
requestId: Double,
|
|
68
|
+
adUnitId: string,
|
|
69
|
+
customData?: string | null
|
|
70
|
+
) => Promise<void>;
|
|
71
|
+
|
|
72
|
+
isAppOpenAdReady: (requestId: Double, adUnitId: string) => Promise<boolean>;
|
|
73
|
+
loadAppOpenAd: (requestId: Double, adUnitId: string) => Promise<void>;
|
|
74
|
+
showAppOpenAd: (
|
|
75
|
+
requestId: Double,
|
|
76
|
+
adUnitId: string,
|
|
77
|
+
placement?: string | null,
|
|
78
|
+
customData?: string | null
|
|
79
|
+
) => Promise<void>;
|
|
80
|
+
|
|
81
|
+
isLightPopupReady: (requestId: Double, adUnitId: string) => Promise<boolean>;
|
|
82
|
+
loadLightPopup: (requestId: Double, adUnitId: string) => Promise<void>;
|
|
83
|
+
showLightPopup: (requestId: Double, adUnitId: string) => Promise<void>;
|
|
84
|
+
setLightPopupAdConfiguration: (
|
|
85
|
+
requestId: Double,
|
|
86
|
+
adUnitId: string,
|
|
87
|
+
configuration: UnsafeObject
|
|
88
|
+
) => Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('DaroMModule');
|
package/src/RewardedAd.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
2
1
|
import {
|
|
3
2
|
addEventListener,
|
|
4
3
|
removeEventListener,
|
|
5
4
|
AdEventEmitter,
|
|
6
5
|
} from './EventEmitter';
|
|
6
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
7
7
|
import type {
|
|
8
8
|
AdDisplayFailedInfo,
|
|
9
9
|
AdInfo,
|
|
@@ -16,8 +16,6 @@ import {
|
|
|
16
16
|
type RewardedAdEventPayloadMap,
|
|
17
17
|
} from './types/AdEvent';
|
|
18
18
|
|
|
19
|
-
const { DaroMModule } = NativeModules;
|
|
20
|
-
|
|
21
19
|
const {
|
|
22
20
|
ON_REWARDED_AD_LOADED_EVENT,
|
|
23
21
|
ON_REWARDED_AD_LOAD_FAILED_EVENT,
|
|
@@ -27,7 +25,7 @@ const {
|
|
|
27
25
|
ON_REWARDED_AD_HIDDEN_EVENT,
|
|
28
26
|
ON_REWARDED_AD_RECEIVED_REWARD_EVENT,
|
|
29
27
|
ON_REWARDED_AD_IMPRESSION_RECORDED,
|
|
30
|
-
} =
|
|
28
|
+
} = NativeDaroModule.getConstants();
|
|
31
29
|
|
|
32
30
|
const NATIVE_EVENT_BY_TYPE: Record<AdEventType | RewardedAdEventType, string> =
|
|
33
31
|
{
|
|
@@ -59,15 +57,15 @@ export class RewardedAd {
|
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
isAdReady(): Promise<boolean> {
|
|
62
|
-
return
|
|
60
|
+
return NativeDaroModule.isRewardedAdReady(this.requestId, this.adUnitId);
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
load(): void {
|
|
66
|
-
|
|
64
|
+
NativeDaroModule.loadRewardedAd(this.requestId, this.adUnitId);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
show(customData?: string | null): void {
|
|
70
|
-
|
|
68
|
+
NativeDaroModule.showRewardedAd(
|
|
71
69
|
this.requestId,
|
|
72
70
|
this.adUnitId,
|
|
73
71
|
customData ?? null
|
|
@@ -119,19 +117,19 @@ export class RewardedAd {
|
|
|
119
117
|
/** @deprecated `RewardedAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
|
|
120
118
|
static isAdReady(adUnitId: string): Promise<boolean> {
|
|
121
119
|
const requestId = RewardedAd._getLegacyRequestId(adUnitId);
|
|
122
|
-
return
|
|
120
|
+
return NativeDaroModule.isRewardedAdReady(requestId, adUnitId);
|
|
123
121
|
}
|
|
124
122
|
|
|
125
123
|
/** @deprecated `RewardedAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
|
|
126
124
|
static loadAd(adUnitId: string): void {
|
|
127
125
|
const requestId = RewardedAd._getLegacyRequestId(adUnitId);
|
|
128
|
-
|
|
126
|
+
NativeDaroModule.loadRewardedAd(requestId, adUnitId);
|
|
129
127
|
}
|
|
130
128
|
|
|
131
129
|
/** @deprecated `RewardedAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
|
|
132
130
|
static showAd(adUnitId: string, customData?: string | null): void {
|
|
133
131
|
const requestId = RewardedAd._getLegacyRequestId(adUnitId);
|
|
134
|
-
|
|
132
|
+
NativeDaroModule.showRewardedAd(requestId, adUnitId, customData ?? null);
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
/** @deprecated `addAdEventListener(AdEventType.LOADED, ...)`를 인스턴스에서 사용하세요. */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
declare module 'react-native/Libraries/Types/CodegenTypes' {
|
|
2
|
+
import type { NativeSyntheticEvent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export type DirectEventHandler<
|
|
5
|
+
T,
|
|
6
|
+
PaperName extends string | never = never,
|
|
7
|
+
> = [PaperName] extends [never]
|
|
8
|
+
? (event: NativeSyntheticEvent<T>) => void | Promise<void>
|
|
9
|
+
: (event: NativeSyntheticEvent<T>) => void | Promise<void>;
|
|
10
|
+
export type Int32 = number;
|
|
11
|
+
export type Double = number;
|
|
12
|
+
export type UnsafeObject = object;
|
|
13
|
+
export type UnsafeMixed = unknown;
|
|
14
|
+
export type WithDefault<Type, Value> = Type | (Value & never);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare module 'react-native/Libraries/Utilities/codegenNativeCommands' {
|
|
18
|
+
export interface Options<T extends string> {
|
|
19
|
+
readonly supportedCommands: ReadonlyArray<T>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function codegenNativeCommands<T extends object>(
|
|
23
|
+
options: Options<keyof T extends string ? keyof T : never>
|
|
24
|
+
): T;
|
|
25
|
+
|
|
26
|
+
export default codegenNativeCommands;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module 'react-native/Libraries/Utilities/codegenNativeComponent' {
|
|
30
|
+
import type { HostComponent } from 'react-native';
|
|
31
|
+
|
|
32
|
+
export interface Options {
|
|
33
|
+
readonly interfaceOnly?: boolean | undefined;
|
|
34
|
+
readonly paperComponentName?: string | undefined;
|
|
35
|
+
readonly paperComponentNameDeprecated?: string | undefined;
|
|
36
|
+
readonly excludedPlatforms?: ReadonlyArray<'iOS' | 'android'> | undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function codegenNativeComponent<Props extends object>(
|
|
40
|
+
componentName: string,
|
|
41
|
+
options?: Options
|
|
42
|
+
): HostComponent<Props>;
|
|
43
|
+
|
|
44
|
+
export default codegenNativeComponent;
|
|
45
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { InterstitialAd } from '../InterstitialAd';
|
|
3
|
+
import { AdEventType } from '../types/AdEvent';
|
|
4
|
+
import type {
|
|
5
|
+
AdDisplayFailedInfo,
|
|
6
|
+
AdInfo,
|
|
7
|
+
AdLoadFailedInfo,
|
|
8
|
+
} from '../types/AdInfo';
|
|
9
|
+
|
|
10
|
+
export type UseInterstitialAdOptions = {
|
|
11
|
+
onLoaded?: (adInfo: AdInfo) => void;
|
|
12
|
+
onLoadFailed?: (error: AdLoadFailedInfo) => void;
|
|
13
|
+
onClicked?: (adInfo: AdInfo) => void;
|
|
14
|
+
onDisplayed?: (adInfo: AdInfo) => void;
|
|
15
|
+
onFailedToDisplay?: (error: AdDisplayFailedInfo) => void;
|
|
16
|
+
onHidden?: (adInfo: AdInfo) => void;
|
|
17
|
+
onImpressionRecorded?: (adInfo: AdInfo) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type UseInterstitialAdResult = {
|
|
21
|
+
isLoaded: boolean;
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
load: () => void;
|
|
24
|
+
show: () => void;
|
|
25
|
+
isAdReady: () => Promise<boolean>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function useInterstitialAd(
|
|
29
|
+
adUnitId: string | null,
|
|
30
|
+
options: UseInterstitialAdOptions = {}
|
|
31
|
+
): UseInterstitialAdResult {
|
|
32
|
+
const adRef = useRef<InterstitialAd | null>(null);
|
|
33
|
+
const optionsRef = useRef(options);
|
|
34
|
+
optionsRef.current = options;
|
|
35
|
+
const [state, setState] = useState({
|
|
36
|
+
isLoaded: false,
|
|
37
|
+
isLoading: false,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const load = useCallback(() => {
|
|
41
|
+
if (!adUnitId) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ad = adRef.current;
|
|
46
|
+
if (!ad) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setState({ isLoaded: false, isLoading: true });
|
|
51
|
+
ad.load();
|
|
52
|
+
}, [adUnitId]);
|
|
53
|
+
|
|
54
|
+
const show = useCallback(() => {
|
|
55
|
+
adRef.current?.show();
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
const isAdReady = useCallback(async () => {
|
|
59
|
+
const isLoaded = (await adRef.current?.isAdReady()) ?? false;
|
|
60
|
+
setState((prevState) => ({ ...prevState, isLoaded }));
|
|
61
|
+
return isLoaded;
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
adRef.current?.removeAllListeners();
|
|
66
|
+
adRef.current = null;
|
|
67
|
+
setState({ isLoaded: false, isLoading: false });
|
|
68
|
+
|
|
69
|
+
if (!adUnitId) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const ad = InterstitialAd.createForAdRequest(adUnitId);
|
|
74
|
+
adRef.current = ad;
|
|
75
|
+
|
|
76
|
+
ad.addAdEventListener(AdEventType.LOADED, (info) => {
|
|
77
|
+
setState({ isLoaded: true, isLoading: false });
|
|
78
|
+
optionsRef.current.onLoaded?.(info);
|
|
79
|
+
});
|
|
80
|
+
ad.addAdEventListener(AdEventType.LOAD_FAILED, (error) => {
|
|
81
|
+
setState({ isLoaded: false, isLoading: false });
|
|
82
|
+
optionsRef.current.onLoadFailed?.(error);
|
|
83
|
+
});
|
|
84
|
+
ad.addAdEventListener(AdEventType.DISPLAYED, (info) => {
|
|
85
|
+
setState((prevState) => ({ ...prevState, isLoaded: false }));
|
|
86
|
+
optionsRef.current.onDisplayed?.(info);
|
|
87
|
+
});
|
|
88
|
+
ad.addAdEventListener(AdEventType.FAILED_TO_DISPLAY, (error) => {
|
|
89
|
+
setState({ isLoaded: false, isLoading: false });
|
|
90
|
+
optionsRef.current.onFailedToDisplay?.(error);
|
|
91
|
+
});
|
|
92
|
+
ad.addAdEventListener(AdEventType.HIDDEN, (info) => {
|
|
93
|
+
setState((prevState) => ({ ...prevState, isLoaded: false }));
|
|
94
|
+
optionsRef.current.onHidden?.(info);
|
|
95
|
+
});
|
|
96
|
+
ad.addAdEventListener(AdEventType.CLICKED, (info) => {
|
|
97
|
+
optionsRef.current.onClicked?.(info);
|
|
98
|
+
});
|
|
99
|
+
ad.addAdEventListener(AdEventType.IMPRESSION_RECORDED, (info) => {
|
|
100
|
+
optionsRef.current.onImpressionRecorded?.(info);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return () => {
|
|
104
|
+
ad.removeAllListeners();
|
|
105
|
+
if (adRef.current === ad) {
|
|
106
|
+
adRef.current = null;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}, [adUnitId]);
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
...state,
|
|
113
|
+
load,
|
|
114
|
+
show,
|
|
115
|
+
isAdReady,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { LightPopupAd } from '../LightPopupAd';
|
|
3
|
+
import { AdEventType } from '../types/AdEvent';
|
|
4
|
+
import type {
|
|
5
|
+
AdDisplayFailedInfo,
|
|
6
|
+
AdInfo,
|
|
7
|
+
AdLoadFailedInfo,
|
|
8
|
+
} from '../types/AdInfo';
|
|
9
|
+
import type { LightPopupAdConfiguration } from '../types/LightPopupAd';
|
|
10
|
+
|
|
11
|
+
export type UseLightPopupAdOptions = {
|
|
12
|
+
onLoaded?: (adInfo: AdInfo) => void;
|
|
13
|
+
onLoadFailed?: (error: AdLoadFailedInfo) => void;
|
|
14
|
+
onClicked?: (adInfo: AdInfo) => void;
|
|
15
|
+
onDisplayed?: (adInfo: AdInfo) => void;
|
|
16
|
+
onFailedToDisplay?: (error: AdDisplayFailedInfo) => void;
|
|
17
|
+
onHidden?: (adInfo: AdInfo) => void;
|
|
18
|
+
onImpressionRecorded?: (adInfo: AdInfo) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type UseLightPopupAdLoadOptions = {
|
|
22
|
+
configuration?: LightPopupAdConfiguration;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type UseLightPopupAdResult = {
|
|
26
|
+
isLoaded: boolean;
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
load: (options?: UseLightPopupAdLoadOptions) => void;
|
|
29
|
+
show: () => void;
|
|
30
|
+
isAdReady: () => Promise<boolean>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function useLightPopupAd(
|
|
34
|
+
adUnitId: string | null,
|
|
35
|
+
options: UseLightPopupAdOptions = {}
|
|
36
|
+
): UseLightPopupAdResult {
|
|
37
|
+
const adRef = useRef<LightPopupAd | null>(null);
|
|
38
|
+
const optionsRef = useRef(options);
|
|
39
|
+
optionsRef.current = options;
|
|
40
|
+
const [state, setState] = useState({
|
|
41
|
+
isLoaded: false,
|
|
42
|
+
isLoading: false,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const createAd = useCallback(() => {
|
|
46
|
+
if (!adUnitId) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
adRef.current?.removeAllListeners();
|
|
51
|
+
|
|
52
|
+
const ad = LightPopupAd.createForAdRequest(adUnitId);
|
|
53
|
+
adRef.current = ad;
|
|
54
|
+
|
|
55
|
+
ad.addAdEventListener(AdEventType.LOADED, (info) => {
|
|
56
|
+
setState({ isLoaded: true, isLoading: false });
|
|
57
|
+
optionsRef.current.onLoaded?.(info);
|
|
58
|
+
});
|
|
59
|
+
ad.addAdEventListener(AdEventType.LOAD_FAILED, (error) => {
|
|
60
|
+
setState({ isLoaded: false, isLoading: false });
|
|
61
|
+
optionsRef.current.onLoadFailed?.(error);
|
|
62
|
+
});
|
|
63
|
+
ad.addAdEventListener(AdEventType.DISPLAYED, (info) => {
|
|
64
|
+
setState((prevState) => ({ ...prevState, isLoaded: false }));
|
|
65
|
+
optionsRef.current.onDisplayed?.(info);
|
|
66
|
+
});
|
|
67
|
+
ad.addAdEventListener(AdEventType.FAILED_TO_DISPLAY, (error) => {
|
|
68
|
+
setState({ isLoaded: false, isLoading: false });
|
|
69
|
+
optionsRef.current.onFailedToDisplay?.(error);
|
|
70
|
+
});
|
|
71
|
+
ad.addAdEventListener(AdEventType.HIDDEN, (info) => {
|
|
72
|
+
setState((prevState) => ({ ...prevState, isLoaded: false }));
|
|
73
|
+
optionsRef.current.onHidden?.(info);
|
|
74
|
+
});
|
|
75
|
+
ad.addAdEventListener(AdEventType.CLICKED, (info) => {
|
|
76
|
+
optionsRef.current.onClicked?.(info);
|
|
77
|
+
});
|
|
78
|
+
ad.addAdEventListener(AdEventType.IMPRESSION_RECORDED, (info) => {
|
|
79
|
+
optionsRef.current.onImpressionRecorded?.(info);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return ad;
|
|
83
|
+
}, [adUnitId]);
|
|
84
|
+
|
|
85
|
+
const load = useCallback(
|
|
86
|
+
(loadOptions?: UseLightPopupAdLoadOptions) => {
|
|
87
|
+
const ad = createAd();
|
|
88
|
+
if (!ad) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setState({ isLoaded: false, isLoading: true });
|
|
93
|
+
|
|
94
|
+
if (loadOptions?.configuration) {
|
|
95
|
+
ad.setConfiguration(loadOptions.configuration);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
ad.load();
|
|
99
|
+
},
|
|
100
|
+
[createAd]
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const show = useCallback(() => {
|
|
104
|
+
adRef.current?.show();
|
|
105
|
+
}, []);
|
|
106
|
+
|
|
107
|
+
const isAdReady = useCallback(async () => {
|
|
108
|
+
const isLoaded = (await adRef.current?.isAdReady()) ?? false;
|
|
109
|
+
setState((prevState) => ({ ...prevState, isLoaded }));
|
|
110
|
+
return isLoaded;
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
adRef.current?.removeAllListeners();
|
|
115
|
+
adRef.current = null;
|
|
116
|
+
setState({ isLoaded: false, isLoading: false });
|
|
117
|
+
}, [adUnitId]);
|
|
118
|
+
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
return () => {
|
|
121
|
+
adRef.current?.removeAllListeners();
|
|
122
|
+
adRef.current = null;
|
|
123
|
+
};
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
...state,
|
|
128
|
+
load,
|
|
129
|
+
show,
|
|
130
|
+
isAdReady,
|
|
131
|
+
};
|
|
132
|
+
}
|