react-native-daro 2.0.0-rc.1 → 2.0.1
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/README.md +13 -1
- package/android/build.gradle +12 -1
- package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +23 -8
- package/android/src/main/java/com/daro/reactnative/DaroSdkBridge.kt +52 -7
- package/android/src/main/java/com/daro/reactnative/event/DaroRNEvent.kt +2 -1
- package/android/src/main/java/com/daro/reactnative/impl/DaroRNLightPopupModuleImpl.kt +86 -73
- package/android/src/main/java/com/daro/reactnative/impl/LightPopupRequest.kt +51 -0
- package/android/src/main/java/com/daro/reactnative/view/DaroRNAdNativeViewContainer.kt +20 -0
- package/android/src/oldarch/java/com/daro/reactnative/DaroRNModuleSpec.kt +6 -0
- package/android/src/test/AndroidManifest.xml +10 -0
- package/android/src/test/java/com/daro/reactnative/DaroSdkBridgeTest.kt +144 -0
- package/android/src/test/java/com/daro/reactnative/impl/LightPopupRequestTest.kt +62 -0
- package/ios/DaroRNModule+LightPopup.swift +130 -102
- package/ios/DaroRNModule+Qa.swift +38 -37
- package/ios/DaroRNModule.mm +2 -0
- package/ios/DaroRNModule.swift +39 -20
- package/ios/Fabric/DaroRNNativeAdComponentView.mm +14 -0
- package/ios/Paper/DaroRNNativeAdViewManager.m +1 -0
- package/ios/Shared/DaroRNAdEventSink.swift +1 -0
- package/ios/Shared/DaroRNInitialization.swift +47 -0
- package/ios/Shared/DaroRNNativeAdView.swift +8 -0
- package/lib/commonjs/DaroRNNativeAdViewNativeComponent.ts +3 -0
- package/lib/commonjs/LightPopupAd.js +15 -1
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/NativeDaroModule.js.map +1 -1
- package/lib/commonjs/hooks/useLightPopupAd.js +6 -4
- package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -1
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +7 -0
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/types/NativeAdViewProps.js +21 -0
- package/lib/commonjs/types/NativeAdViewProps.js.map +1 -1
- package/lib/module/DaroRNNativeAdViewNativeComponent.ts +3 -0
- package/lib/module/LightPopupAd.js +15 -1
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/NativeDaroModule.js.map +1 -1
- package/lib/module/hooks/useLightPopupAd.js +6 -4
- package/lib/module/hooks/useLightPopupAd.js.map +1 -1
- package/lib/module/index.js +15 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +7 -0
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/types/NativeAdViewProps.js +22 -1
- package/lib/module/types/NativeAdViewProps.js.map +1 -1
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts +3 -0
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts +3 -0
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +2 -0
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +11 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +2 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +9 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts +3 -0
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/LightPopupAd.d.ts +3 -0
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeDaroModule.d.ts +2 -0
- package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +11 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +2 -0
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +9 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +6 -3
- package/plugin/build/withAndroid.js +2 -2
- package/react-native-daro.podspec +1 -1
- package/src/DaroRNNativeAdViewNativeComponent.ts +3 -0
- package/src/LightPopupAd.ts +18 -1
- package/src/NativeDaroModule.ts +2 -0
- package/src/hooks/useLightPopupAd.ts +6 -4
- package/src/index.tsx +14 -0
- package/src/nativeAd/NativeAdView.tsx +21 -0
- package/src/types/NativeAdViewProps.ts +10 -0
|
@@ -47,7 +47,7 @@ export function useLightPopupAd(
|
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
adRef.current?.
|
|
50
|
+
adRef.current?.destroy();
|
|
51
51
|
|
|
52
52
|
const ad = LightPopupAd.createForAdRequest(adUnitId);
|
|
53
53
|
adRef.current = ad;
|
|
@@ -105,20 +105,22 @@ export function useLightPopupAd(
|
|
|
105
105
|
}, []);
|
|
106
106
|
|
|
107
107
|
const isAdReady = useCallback(async () => {
|
|
108
|
-
const
|
|
108
|
+
const ad = adRef.current;
|
|
109
|
+
const isLoaded = (await ad?.isAdReady()) ?? false;
|
|
110
|
+
if (adRef.current !== ad) return false;
|
|
109
111
|
setState((prevState) => ({ ...prevState, isLoaded }));
|
|
110
112
|
return isLoaded;
|
|
111
113
|
}, []);
|
|
112
114
|
|
|
113
115
|
useEffect(() => {
|
|
114
|
-
adRef.current?.
|
|
116
|
+
adRef.current?.destroy();
|
|
115
117
|
adRef.current = null;
|
|
116
118
|
setState({ isLoaded: false, isLoading: false });
|
|
117
119
|
}, [adUnitId]);
|
|
118
120
|
|
|
119
121
|
useEffect(() => {
|
|
120
122
|
return () => {
|
|
121
|
-
adRef.current?.
|
|
123
|
+
adRef.current?.destroy();
|
|
122
124
|
adRef.current = null;
|
|
123
125
|
};
|
|
124
126
|
}, []);
|
package/src/index.tsx
CHANGED
|
@@ -31,10 +31,24 @@ export {
|
|
|
31
31
|
TitleView,
|
|
32
32
|
} from './nativeAd/NativeAdViewComponents';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Initialize the native SDK. Resolves after the latest mute setting is applied.
|
|
36
|
+
* RN defaults to muted. Set an explicit value before initialization to override it.
|
|
37
|
+
*/
|
|
34
38
|
export async function initialize() {
|
|
35
39
|
await NativeDaroModule.initializeSdk();
|
|
36
40
|
}
|
|
37
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Set app-wide ad audio. Defaults to true for RN; false explicitly enables sound.
|
|
44
|
+
* Before/during initialization the latest value is retained across JS reloads.
|
|
45
|
+
* Await initialize() before loading ads. Already-loaded ads and mediation routes
|
|
46
|
+
* that do not support the native SDK mute setting may not change retroactively.
|
|
47
|
+
*/
|
|
48
|
+
export async function setAppMuted(muted: boolean): Promise<void> {
|
|
49
|
+
await NativeDaroModule.setAppMuted(muted);
|
|
50
|
+
}
|
|
51
|
+
|
|
38
52
|
export async function isInitialized(): Promise<boolean> {
|
|
39
53
|
return NativeDaroModule.isInitialized();
|
|
40
54
|
}
|
|
@@ -15,6 +15,7 @@ import NativeAdViewNativeComponent, {
|
|
|
15
15
|
import NativeDaroModule from '../NativeDaroModule';
|
|
16
16
|
import type { AdNativeEvent } from '../types/AdEvent';
|
|
17
17
|
import type { AdInfo, AdLoadFailedInfo } from '../types/AdInfo';
|
|
18
|
+
import { NativeAdAssetType } from '../types/NativeAdViewProps';
|
|
18
19
|
import type {
|
|
19
20
|
NativeAdViewHandler,
|
|
20
21
|
NativeAdViewProps,
|
|
@@ -26,6 +27,10 @@ import {
|
|
|
26
27
|
|
|
27
28
|
type NativeAdViewElement = ElementRef<typeof NativeAdViewNativeComponent>;
|
|
28
29
|
|
|
30
|
+
const KNOWN_NATIVE_AD_ASSET_TYPES: ReadonlySet<string> = new Set(
|
|
31
|
+
Object.values(NativeAdAssetType)
|
|
32
|
+
);
|
|
33
|
+
|
|
29
34
|
export const NativeAdView = forwardRef<
|
|
30
35
|
NativeAdViewHandler,
|
|
31
36
|
NativeAdViewProps & ViewProps
|
|
@@ -65,6 +70,7 @@ const NativeAdViewImpl = forwardRef<
|
|
|
65
70
|
{
|
|
66
71
|
adUnitId,
|
|
67
72
|
onAdLoaded,
|
|
73
|
+
onNativeAdAssetLoaded,
|
|
68
74
|
onAdLoadFailed,
|
|
69
75
|
onAdClicked,
|
|
70
76
|
onAdImpressionRecorded,
|
|
@@ -93,6 +99,20 @@ const NativeAdViewImpl = forwardRef<
|
|
|
93
99
|
nativeAdViewRef.current = element;
|
|
94
100
|
}, []);
|
|
95
101
|
|
|
102
|
+
const onNativeAdAssetLoadedEvent = useCallback(
|
|
103
|
+
(event: { nativeEvent: { assetTypes: readonly string[] } }) => {
|
|
104
|
+
onNativeAdAssetLoaded?.(
|
|
105
|
+
new Set(
|
|
106
|
+
event.nativeEvent.assetTypes.filter(
|
|
107
|
+
(value): value is NativeAdAssetType =>
|
|
108
|
+
KNOWN_NATIVE_AD_ASSET_TYPES.has(value)
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
[onNativeAdAssetLoaded]
|
|
114
|
+
);
|
|
115
|
+
|
|
96
116
|
const onAdLoadedEvent = useCallback(
|
|
97
117
|
(event: AdNativeEvent<AdInfo>) => {
|
|
98
118
|
onAdLoaded?.(event.nativeEvent);
|
|
@@ -150,6 +170,7 @@ const NativeAdViewImpl = forwardRef<
|
|
|
150
170
|
mediaViewStyleProps={
|
|
151
171
|
nativeAdAssetRegistrations.mediaView?.styleProps ?? null
|
|
152
172
|
}
|
|
173
|
+
onNativeAdAssetLoadedEvent={onNativeAdAssetLoadedEvent}
|
|
153
174
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
154
175
|
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
155
176
|
onAdClickedEvent={onAdClickedEvent}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { AdProps } from './AdProps';
|
|
2
2
|
|
|
3
|
+
export enum NativeAdAssetType {
|
|
4
|
+
TITLE = 'title', // 광고 제목
|
|
5
|
+
BODY = 'body', // 광고 본문
|
|
6
|
+
ICON = 'icon', // 광고 아이콘
|
|
7
|
+
MEDIA = 'media', // 광고 이미지 또는 동영상
|
|
8
|
+
CALL_TO_ACTION = 'callToAction', // 행동 유도 버튼 문구
|
|
9
|
+
ADVERTISER = 'advertiser', // 광고주명
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
export type AdChoicesPosition =
|
|
4
13
|
| 'topLeft'
|
|
5
14
|
| 'topRight'
|
|
@@ -20,6 +29,7 @@ export type NativeAdViewHandler = {
|
|
|
20
29
|
* Represents a {@link NativeAdView}.
|
|
21
30
|
*/
|
|
22
31
|
export type NativeAdViewProps = AdProps & {
|
|
32
|
+
onNativeAdAssetLoaded?: (assetTypes: ReadonlySet<NativeAdAssetType>) => void;
|
|
23
33
|
loadOnMount?: boolean;
|
|
24
34
|
adChoicesPosition?: AdChoicesPosition;
|
|
25
35
|
};
|