react-native-daro 1.0.16 → 2.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/README.md +2 -5
- package/android/build.gradle +7 -13
- package/android/src/main/java/com/daro/reactnative/DaroRNAdBannerViewManager.kt +105 -0
- package/android/src/main/java/com/daro/reactnative/{DaroMAdNativeViewManager.kt → DaroRNAdNativeViewManager.kt} +34 -38
- package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +388 -0
- package/android/src/main/java/com/daro/reactnative/{DaroMPackage.kt → DaroRNPackage.kt} +7 -7
- package/android/src/main/java/com/daro/reactnative/DaroSdkBridge.kt +52 -0
- package/android/src/main/java/com/daro/reactnative/constants/{InternalDaroMBannerSize.kt → InternalDaroRNBannerSize.kt} +2 -2
- package/android/src/main/java/com/daro/reactnative/event/{DaroMEvent.kt → DaroRNEvent.kt} +8 -7
- package/android/src/main/java/com/daro/reactnative/impl/{DaroMBannerViewModuleImpl.kt → DaroRNBannerViewModuleImpl.kt} +3 -3
- package/android/src/main/java/com/daro/reactnative/impl/{DaroMInterstitialModuleImpl.kt → DaroRNInterstitialModuleImpl.kt} +4 -4
- package/android/src/main/java/com/daro/reactnative/impl/DaroRNLightPopupModuleImpl.kt +163 -0
- package/android/src/main/java/com/daro/reactnative/impl/{DaroMRewardedAdModuleImpl.kt → DaroRNRewardedAdModuleImpl.kt} +4 -4
- package/android/src/main/java/com/daro/reactnative/impl/LightPopupRequest.kt +51 -0
- package/android/src/main/java/com/daro/reactnative/util/AdInfoUtil.kt +12 -0
- package/android/src/main/java/com/daro/reactnative/util/DaroQaProbe.kt +147 -0
- package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +2 -2
- package/android/src/main/java/com/daro/reactnative/view/{DaroMAdBannerViewContainer.kt → DaroRNAdBannerViewContainer.kt} +2 -3
- package/android/src/main/java/com/daro/reactnative/view/{DaroMAdNativeViewContainer.kt → DaroRNAdNativeViewContainer.kt} +23 -4
- package/android/src/newarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt} +1 -1
- package/android/src/oldarch/java/com/daro/reactnative/{DaroMModuleSpec.kt → DaroRNModuleSpec.kt} +35 -3
- package/android/src/test/java/com/daro/reactnative/impl/LightPopupRequestTest.kt +62 -0
- package/ios/{DaroMModule+AppOpen.swift → DaroRNModule+AppOpen.swift} +10 -11
- package/ios/DaroRNModule+Consent.swift +88 -0
- package/ios/{DaroMModule+Interstitial.swift → DaroRNModule+Interstitial.swift} +9 -9
- package/ios/DaroRNModule+LightPopup.swift +211 -0
- package/ios/DaroRNModule+Qa.swift +159 -0
- package/ios/{DaroMModule+Rewarded.swift → DaroRNModule+Rewarded.swift} +10 -10
- package/ios/{DaroMModule.mm → DaroRNModule.mm} +20 -4
- package/ios/{DaroMModule.swift → DaroRNModule.swift} +32 -6
- package/ios/Fabric/DaroRNAdBannerComponentView.mm +219 -0
- package/ios/Fabric/{DaroMFabricEventSink.mm → DaroRNFabricEventSink.mm} +4 -4
- package/ios/Fabric/{DaroMFabricPropApplier.mm → DaroRNFabricPropApplier.mm} +14 -14
- package/ios/Fabric/DaroRNNativeAdComponentView.mm +320 -0
- package/ios/Paper/{DaroMAdBannerViewManager.m → DaroRNAdBannerViewManager.m} +1 -1
- package/ios/Paper/{DaroMAdBannerViewManager.swift → DaroRNAdBannerViewManager.swift} +5 -5
- package/ios/Paper/{DaroMNativeAdViewManager.m → DaroRNNativeAdViewManager.m} +2 -1
- package/ios/Paper/DaroRNNativeAdViewManager.swift +22 -0
- package/ios/Shared/DaroMediationDebugger.swift +14 -0
- package/ios/Shared/{DaroMAdEventSink.swift → DaroRNAdEventSink.swift} +2 -1
- package/ios/Shared/{DaroMBannerAdView.swift → DaroRNBannerAdView.swift} +11 -11
- package/ios/Shared/{DaroMNativeAdLoadCoordinator.swift → DaroRNNativeAdLoadCoordinator.swift} +4 -4
- package/ios/Shared/{DaroMNativeAdView.swift → DaroRNNativeAdView.swift} +29 -21
- package/ios/Shared/{DaroMNativeAssetResolver.swift → DaroRNNativeAssetResolver.swift} +6 -6
- package/lib/commonjs/AdBannerView.js +3 -5
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +4 -4
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/{DaroMAdBannerViewNativeComponent.ts → DaroRNAdBannerViewNativeComponent.ts} +5 -2
- package/{src/DaroMNativeAdViewNativeComponent.ts → lib/commonjs/DaroRNNativeAdViewNativeComponent.ts} +8 -2
- package/lib/commonjs/LightPopupAd.js +15 -1
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/NativeDaroModule.js +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 +121 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +10 -3
- 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/AdBannerView.js +1 -3
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +4 -4
- package/lib/module/AppOpenAd.js.map +1 -1
- package/{src/DaroMAdBannerViewNativeComponent.ts → lib/module/DaroRNAdBannerViewNativeComponent.ts} +5 -2
- package/lib/{commonjs/DaroMNativeAdViewNativeComponent.ts → module/DaroRNNativeAdViewNativeComponent.ts} +8 -2
- package/lib/module/LightPopupAd.js +15 -1
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/NativeDaroModule.js +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 +101 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +8 -1
- 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/plugin/src/index.d.ts +2 -6
- package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +2 -6
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts +2 -6
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts +2 -2
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/{DaroMAdBannerViewNativeComponent.d.ts → DaroRNAdBannerViewNativeComponent.d.ts} +3 -2
- package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/{DaroMNativeAdViewNativeComponent.d.ts → DaroRNNativeAdViewNativeComponent.d.ts} +6 -2
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
- 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 +11 -1
- 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 +79 -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/AdInfo.d.ts +15 -0
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts +0 -1
- package/lib/typescript/commonjs/src/types/AdProps.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/plugin/src/index.d.ts +2 -6
- package/lib/typescript/module/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withAndroid.d.ts +2 -6
- package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withIos.d.ts +2 -6
- package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/module/src/AppOpenAd.d.ts +2 -2
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/module/src/{DaroMAdBannerViewNativeComponent.d.ts → DaroRNAdBannerViewNativeComponent.d.ts} +3 -2
- package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/{DaroMNativeAdViewNativeComponent.d.ts → DaroRNNativeAdViewNativeComponent.d.ts} +6 -2
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
- 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 +11 -1
- 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 +79 -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/AdInfo.d.ts +15 -0
- package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdProps.d.ts +0 -1
- package/lib/typescript/module/src/types/AdProps.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 +8 -5
- package/plugin/build/index.d.ts +2 -6
- package/plugin/build/index.js +21 -56
- package/plugin/build/withAndroid.d.ts +2 -6
- package/plugin/build/withAndroid.js +48 -90
- package/plugin/build/withIos.d.ts +2 -6
- package/plugin/build/withIos.js +37 -33
- package/react-native-daro.podspec +2 -3
- package/src/AdBannerView.tsx +1 -3
- package/src/AppOpenAd.ts +2 -8
- package/{lib/module/DaroMAdBannerViewNativeComponent.ts → src/DaroRNAdBannerViewNativeComponent.ts} +5 -2
- package/{lib/module/DaroMNativeAdViewNativeComponent.ts → src/DaroRNNativeAdViewNativeComponent.ts} +8 -2
- package/src/LightPopupAd.ts +18 -1
- package/src/NativeDaroModule.ts +18 -2
- package/src/hooks/useLightPopupAd.ts +6 -4
- package/src/index.tsx +136 -0
- package/src/nativeAd/NativeAdView.tsx +22 -1
- package/src/types/AdInfo.ts +17 -0
- package/src/types/AdProps.ts +0 -2
- package/src/types/NativeAdViewProps.ts +10 -0
- package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +0 -23
- package/android/src/main/java/com/daro/reactnative/DaroMAdBannerViewManager.kt +0 -155
- package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +0 -257
- package/android/src/main/java/com/daro/reactnative/impl/DaroMLightPopupModuleImpl.kt +0 -150
- package/ios/DaroMModule+LightPopup.swift +0 -183
- package/ios/Fabric/DaroMAdBannerComponentView.mm +0 -207
- package/ios/Fabric/DaroMNativeAdComponentView.mm +0 -294
- package/ios/Paper/DaroMNativeAdViewManager.swift +0 -22
- package/ios/mediation/admob/DaroMediationDebugger.swift +0 -11
- package/lib/commonjs/types/DaroMMobileAds.js +0 -2
- package/lib/commonjs/types/DaroMMobileAds.js.map +0 -1
- package/lib/module/types/DaroMMobileAds.js +0 -2
- package/lib/module/types/DaroMMobileAds.js.map +0 -1
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts +0 -6
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +0 -1
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts +0 -6
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +0 -1
- package/src/types/DaroMMobileAds.ts +0 -5
- /package/ios/{mediation/admob → Shared}/DaroMediationTypes.swift +0 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
#import <React/RCTDefines.h>
|
|
2
|
+
|
|
3
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
+
|
|
5
|
+
#import <React/RCTComponent.h>
|
|
6
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
|
+
#import <React/RCTViewComponentView.h>
|
|
8
|
+
#import <react/renderer/components/DaroReactNativeSpec/ComponentDescriptors.h>
|
|
9
|
+
#import <react/renderer/components/DaroReactNativeSpec/EventEmitters.h>
|
|
10
|
+
#import <react/renderer/components/DaroReactNativeSpec/Props.h>
|
|
11
|
+
#import <react/renderer/components/DaroReactNativeSpec/RCTComponentViewHelpers.h>
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
using namespace facebook::react;
|
|
16
|
+
|
|
17
|
+
extern UIView *DaroRNFabricCreateSwiftView(NSString *className);
|
|
18
|
+
extern void DaroRNFabricSetValue(UIView *view, NSString *key, id value);
|
|
19
|
+
extern void DaroRNFabricPerformSelector(UIView *view, SEL selector);
|
|
20
|
+
extern void DaroRNFabricPerformSelectorWithObject(UIView *view, SEL selector, id object);
|
|
21
|
+
extern void DaroRNFabricPerformSelectorWithTwoObjects(UIView *view, SEL selector, id firstObject, id secondObject);
|
|
22
|
+
extern NSString *DaroRNFabricNSStringFromStdString(const std::string &value);
|
|
23
|
+
extern id DaroRNFabricIdFromDynamic(const folly::dynamic &value);
|
|
24
|
+
extern NSDictionary *DaroRNFabricEventBody(NSDictionary *body);
|
|
25
|
+
extern std::string DaroRNFabricEventString(NSDictionary *body, NSString *key);
|
|
26
|
+
extern double DaroRNFabricEventDouble(NSDictionary *body, NSString *key);
|
|
27
|
+
extern int DaroRNFabricEventInt(NSDictionary *body, NSString *key);
|
|
28
|
+
|
|
29
|
+
static NSString *DaroRNFabricAdChoicesPositionString(DaroRNNativeAdViewAdChoicesPosition position)
|
|
30
|
+
{
|
|
31
|
+
switch (position) {
|
|
32
|
+
case DaroRNNativeAdViewAdChoicesPosition::TopLeft:
|
|
33
|
+
return @"topLeft";
|
|
34
|
+
case DaroRNNativeAdViewAdChoicesPosition::TopRight:
|
|
35
|
+
return @"topRight";
|
|
36
|
+
case DaroRNNativeAdViewAdChoicesPosition::BottomLeft:
|
|
37
|
+
return @"bottomLeft";
|
|
38
|
+
case DaroRNNativeAdViewAdChoicesPosition::BottomRight:
|
|
39
|
+
default:
|
|
40
|
+
return @"bottomRight";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@interface DaroRNNativeAdViewComponentView : RCTViewComponentView <RCTDaroRNNativeAdViewViewProtocol>
|
|
45
|
+
@end
|
|
46
|
+
|
|
47
|
+
@implementation DaroRNNativeAdViewComponentView {
|
|
48
|
+
UIView *_nativeAdView;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
+ (void)load
|
|
52
|
+
{
|
|
53
|
+
[super load];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
57
|
+
{
|
|
58
|
+
if (self = [super initWithFrame:frame]) {
|
|
59
|
+
static const auto defaultProps = std::make_shared<const DaroRNNativeAdViewProps>();
|
|
60
|
+
_props = defaultProps;
|
|
61
|
+
[self createNativeAdView];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return self;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)createNativeAdView
|
|
68
|
+
{
|
|
69
|
+
_nativeAdView = DaroRNFabricCreateSwiftView(@"RNDaroRNNativeAdView");
|
|
70
|
+
_nativeAdView.frame = self.bounds;
|
|
71
|
+
_nativeAdView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
72
|
+
DaroRNFabricPerformSelectorWithObject(_nativeAdView, NSSelectorFromString(@"setAssetSearchRootView:"), _nativeAdView);
|
|
73
|
+
[self addSubview:_nativeAdView];
|
|
74
|
+
[self installEventHandlers];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
- (void)installEventHandlers
|
|
78
|
+
{
|
|
79
|
+
__weak DaroRNNativeAdViewComponentView *weakSelf = self;
|
|
80
|
+
|
|
81
|
+
RCTDirectEventBlock onNativeAdAssetLoadedEvent = ^(NSDictionary *body) {
|
|
82
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
83
|
+
if (!strongSelf) return;
|
|
84
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
85
|
+
if (!eventEmitter) return;
|
|
86
|
+
std::vector<std::string> assetTypes;
|
|
87
|
+
for (NSString *value in DaroRNFabricEventBody(body)[@"assetTypes"]) {
|
|
88
|
+
assetTypes.push_back(std::string(value.UTF8String));
|
|
89
|
+
}
|
|
90
|
+
eventEmitter->onNativeAdAssetLoadedEvent({.assetTypes = assetTypes});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
RCTDirectEventBlock onAdLoadedEvent = ^(NSDictionary *body) {
|
|
94
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
95
|
+
if (!strongSelf) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
100
|
+
if (!eventEmitter) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
105
|
+
eventEmitter->onAdLoadedEvent({
|
|
106
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
107
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
108
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
109
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
110
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
111
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
RCTDirectEventBlock onAdLoadFailedEvent = ^(NSDictionary *body) {
|
|
116
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
117
|
+
if (!strongSelf) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
122
|
+
if (!eventEmitter) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
127
|
+
eventEmitter->onAdLoadFailedEvent({
|
|
128
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
129
|
+
.code = DaroRNFabricEventInt(eventBody, @"code"),
|
|
130
|
+
.message = DaroRNFabricEventString(eventBody, @"message"),
|
|
131
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
RCTDirectEventBlock onAdClickedEvent = ^(NSDictionary *body) {
|
|
136
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
137
|
+
if (!strongSelf) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
142
|
+
if (!eventEmitter) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
147
|
+
eventEmitter->onAdClickedEvent({
|
|
148
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
149
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
150
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
151
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
152
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
153
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
RCTDirectEventBlock onAdImpressionRecordedEvent = ^(NSDictionary *body) {
|
|
158
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
159
|
+
if (!strongSelf) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
164
|
+
if (!eventEmitter) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
169
|
+
eventEmitter->onAdImpressionRecordedEvent({
|
|
170
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
171
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
172
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
173
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
174
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
175
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
DaroRNFabricSetValue(_nativeAdView, @"onNativeAdAssetLoadedEvent", onNativeAdAssetLoadedEvent);
|
|
180
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadedEvent", onAdLoadedEvent);
|
|
181
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadFailedEvent", onAdLoadFailedEvent);
|
|
182
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdClickedEvent", onAdClickedEvent);
|
|
183
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdImpressionRecordedEvent", onAdImpressionRecordedEvent);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
187
|
+
{
|
|
188
|
+
return concreteComponentDescriptorProvider<DaroRNNativeAdViewComponentDescriptor>();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
192
|
+
{
|
|
193
|
+
const auto &oldComponentProps = *std::static_pointer_cast<const DaroRNNativeAdViewProps>(_props);
|
|
194
|
+
const auto &newComponentProps = *std::static_pointer_cast<const DaroRNNativeAdViewProps>(props);
|
|
195
|
+
NSMutableArray<NSString *> *changedProps = [NSMutableArray new];
|
|
196
|
+
|
|
197
|
+
if (oldComponentProps.adUnitId != newComponentProps.adUnitId) {
|
|
198
|
+
DaroRNFabricSetValue(_nativeAdView, @"adUnitId", DaroRNFabricNSStringFromStdString(newComponentProps.adUnitId));
|
|
199
|
+
[changedProps addObject:@"adUnitId"];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (oldComponentProps.loadOnMount != newComponentProps.loadOnMount) {
|
|
203
|
+
DaroRNFabricSetValue(_nativeAdView, @"loadOnMount", @(newComponentProps.loadOnMount));
|
|
204
|
+
[changedProps addObject:@"loadOnMount"];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (oldComponentProps.adChoicesPosition != newComponentProps.adChoicesPosition) {
|
|
208
|
+
DaroRNFabricSetValue(
|
|
209
|
+
_nativeAdView, @"adChoicesPosition", DaroRNFabricAdChoicesPositionString(newComponentProps.adChoicesPosition));
|
|
210
|
+
[changedProps addObject:@"adChoicesPosition"];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (oldComponentProps.titleView != newComponentProps.titleView) {
|
|
214
|
+
DaroRNFabricSetValue(_nativeAdView, @"titleView", @(newComponentProps.titleView));
|
|
215
|
+
[changedProps addObject:@"titleView"];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (oldComponentProps.bodyView != newComponentProps.bodyView) {
|
|
219
|
+
DaroRNFabricSetValue(_nativeAdView, @"bodyView", @(newComponentProps.bodyView));
|
|
220
|
+
[changedProps addObject:@"bodyView"];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (oldComponentProps.callToActionView != newComponentProps.callToActionView) {
|
|
224
|
+
DaroRNFabricSetValue(_nativeAdView, @"callToActionView", @(newComponentProps.callToActionView));
|
|
225
|
+
[changedProps addObject:@"callToActionView"];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (oldComponentProps.iconView != newComponentProps.iconView) {
|
|
229
|
+
DaroRNFabricSetValue(_nativeAdView, @"iconView", @(newComponentProps.iconView));
|
|
230
|
+
[changedProps addObject:@"iconView"];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (oldComponentProps.mediaView != newComponentProps.mediaView) {
|
|
234
|
+
DaroRNFabricSetValue(_nativeAdView, @"mediaView", @(newComponentProps.mediaView));
|
|
235
|
+
[changedProps addObject:@"mediaView"];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (oldComponentProps.titleViewStyleProps != newComponentProps.titleViewStyleProps) {
|
|
239
|
+
DaroRNFabricSetValue(_nativeAdView, @"titleViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.titleViewStyleProps));
|
|
240
|
+
[changedProps addObject:@"titleViewStyleProps"];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (oldComponentProps.bodyViewStyleProps != newComponentProps.bodyViewStyleProps) {
|
|
244
|
+
DaroRNFabricSetValue(_nativeAdView, @"bodyViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.bodyViewStyleProps));
|
|
245
|
+
[changedProps addObject:@"bodyViewStyleProps"];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (oldComponentProps.callToActionViewStyleProps != newComponentProps.callToActionViewStyleProps) {
|
|
249
|
+
DaroRNFabricSetValue(
|
|
250
|
+
_nativeAdView, @"callToActionViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.callToActionViewStyleProps));
|
|
251
|
+
[changedProps addObject:@"callToActionViewStyleProps"];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (oldComponentProps.iconViewStyleProps != newComponentProps.iconViewStyleProps) {
|
|
255
|
+
DaroRNFabricSetValue(_nativeAdView, @"iconViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.iconViewStyleProps));
|
|
256
|
+
[changedProps addObject:@"iconViewStyleProps"];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (oldComponentProps.mediaViewStyleProps != newComponentProps.mediaViewStyleProps) {
|
|
260
|
+
DaroRNFabricSetValue(_nativeAdView, @"mediaViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.mediaViewStyleProps));
|
|
261
|
+
[changedProps addObject:@"mediaViewStyleProps"];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
[super updateProps:props oldProps:oldProps];
|
|
265
|
+
|
|
266
|
+
DaroRNFabricPerformSelectorWithObject(_nativeAdView, NSSelectorFromString(@"applyReactProps:"), changedProps);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
270
|
+
{
|
|
271
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
272
|
+
_nativeAdView.frame = self.bounds;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
276
|
+
{
|
|
277
|
+
DaroRNFabricPerformSelectorWithTwoObjects(
|
|
278
|
+
_nativeAdView, NSSelectorFromString(@"insertMountedSubview:atIndex:"), childComponentView, @(index));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
282
|
+
{
|
|
283
|
+
[childComponentView removeFromSuperview];
|
|
284
|
+
DaroRNFabricPerformSelector(_nativeAdView, NSSelectorFromString(@"refreshMountedAssetViews"));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
- (void)loadAd
|
|
288
|
+
{
|
|
289
|
+
DaroRNFabricPerformSelector(_nativeAdView, NSSelectorFromString(@"loadAd"));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
293
|
+
{
|
|
294
|
+
RCTDaroRNNativeAdViewHandleCommand(self, commandName, args);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
- (void)prepareForRecycle
|
|
298
|
+
{
|
|
299
|
+
[super prepareForRecycle];
|
|
300
|
+
DaroRNFabricSetValue(_nativeAdView, @"onNativeAdAssetLoadedEvent", nil);
|
|
301
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadedEvent", nil);
|
|
302
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadFailedEvent", nil);
|
|
303
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdClickedEvent", nil);
|
|
304
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdImpressionRecordedEvent", nil);
|
|
305
|
+
DaroRNFabricPerformSelectorWithObject(_nativeAdView, NSSelectorFromString(@"setAssetSearchRootView:"), nil);
|
|
306
|
+
DaroRNFabricPerformSelector(_nativeAdView, NSSelectorFromString(@"prepareForReuse"));
|
|
307
|
+
DaroRNFabricPerformSelectorWithObject(_nativeAdView, NSSelectorFromString(@"setAssetSearchRootView:"), _nativeAdView);
|
|
308
|
+
[self installEventHandlers];
|
|
309
|
+
static const auto defaultProps = std::make_shared<const DaroRNNativeAdViewProps>();
|
|
310
|
+
_props = defaultProps;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
@end
|
|
314
|
+
|
|
315
|
+
Class<RCTComponentViewProtocol> DaroRNNativeAdViewCls(void)
|
|
316
|
+
{
|
|
317
|
+
return DaroRNNativeAdViewComponentView.class;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
#endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#import <React/RCTViewManager.h>
|
|
2
2
|
|
|
3
|
-
@interface RCT_EXTERN_MODULE(
|
|
3
|
+
@interface RCT_EXTERN_MODULE(DaroRNAdBannerViewManager, RCTViewManager)
|
|
4
4
|
|
|
5
5
|
RCT_EXPORT_VIEW_PROPERTY(adUnitId, NSString)
|
|
6
6
|
RCT_EXPORT_VIEW_PROPERTY(adFormat, NSString)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React
|
|
2
2
|
|
|
3
|
-
@objc(
|
|
4
|
-
class
|
|
5
|
-
override func view() ->
|
|
6
|
-
|
|
3
|
+
@objc(DaroRNAdBannerViewManager)
|
|
4
|
+
class DaroRNAdBannerViewManager: RCTViewManager {
|
|
5
|
+
override func view() -> DaroRNAdBannerView {
|
|
6
|
+
DaroRNAdBannerView()
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
@@ -13,7 +13,7 @@ class DaroMAdBannerViewManager: RCTViewManager {
|
|
|
13
13
|
@objc(loadAd:)
|
|
14
14
|
func loadAd(viewTag: NSNumber) {
|
|
15
15
|
bridge?.uiManager.addUIBlock({ _, viewRegistry in
|
|
16
|
-
if let view = viewRegistry?[viewTag] as?
|
|
16
|
+
if let view = viewRegistry?[viewTag] as? DaroRNAdBannerView {
|
|
17
17
|
view.loadAd()
|
|
18
18
|
}
|
|
19
19
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#import <React/RCTViewManager.h>
|
|
2
2
|
|
|
3
|
-
@interface RCT_EXTERN_MODULE (
|
|
3
|
+
@interface RCT_EXTERN_MODULE (DaroRNNativeAdViewManager, RCTViewManager)
|
|
4
4
|
|
|
5
5
|
RCT_EXPORT_VIEW_PROPERTY(adUnitId, NSString)
|
|
6
6
|
RCT_EXPORT_VIEW_PROPERTY(loadOnMount, BOOL)
|
|
@@ -18,6 +18,7 @@ RCT_EXPORT_VIEW_PROPERTY(callToActionViewStyleProps, NSDictionary)
|
|
|
18
18
|
RCT_EXPORT_VIEW_PROPERTY(iconViewStyleProps, NSDictionary)
|
|
19
19
|
RCT_EXPORT_VIEW_PROPERTY(mediaViewStyleProps, NSDictionary)
|
|
20
20
|
|
|
21
|
+
RCT_EXPORT_VIEW_PROPERTY(onNativeAdAssetLoadedEvent, RCTDirectEventBlock)
|
|
21
22
|
RCT_EXPORT_VIEW_PROPERTY(onAdLoadedEvent, RCTDirectEventBlock)
|
|
22
23
|
RCT_EXPORT_VIEW_PROPERTY(onAdLoadFailedEvent, RCTDirectEventBlock)
|
|
23
24
|
RCT_EXPORT_VIEW_PROPERTY(onAdClickedEvent, RCTDirectEventBlock)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
@objc(DaroRNNativeAdViewManager)
|
|
5
|
+
class DaroRNNativeAdViewManager: RCTViewManager {
|
|
6
|
+
override func view() -> RNDaroRNNativeAdView {
|
|
7
|
+
RNDaroRNNativeAdView(assetResolver: DaroRNBridgeNativeAssetResolver(bridge: bridge))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
11
|
+
false
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@objc(loadAd:)
|
|
15
|
+
func loadAd(viewTag: NSNumber) {
|
|
16
|
+
bridge?.uiManager.addUIBlock({ _, viewRegistry in
|
|
17
|
+
if let view = viewRegistry?[viewTag] as? RNDaroRNNativeAdView {
|
|
18
|
+
view.loadAd()
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Dispatch
|
|
2
|
+
import GoogleMobileAds
|
|
3
|
+
|
|
4
|
+
// 통합 Daro 바이너리에는 미디에이션 디버거 API 가 없다 — Android 의
|
|
5
|
+
// droom.daro.sdk.Daro.openDebugger 에 대응하는 심볼이 iOS 에는 아직 없다(DARO-1390).
|
|
6
|
+
// 그때까지 AdMob Ad Inspector 를 직접 연다. SDK 에 대응이 생기면 이 파일을 교체한다.
|
|
7
|
+
enum DaroMediationDebugger {
|
|
8
|
+
static func show(resolve: @escaping () -> Void) {
|
|
9
|
+
DispatchQueue.main.async {
|
|
10
|
+
MobileAds.shared.presentAdInspector(from: nil) { _ in }
|
|
11
|
+
resolve()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React
|
|
2
2
|
|
|
3
|
-
final class
|
|
3
|
+
final class DaroRNAdEventSink {
|
|
4
|
+
var onNativeAdAssetLoadedEvent: RCTDirectEventBlock?
|
|
4
5
|
var onAdLoadedEvent: RCTDirectEventBlock?
|
|
5
6
|
var onAdLoadFailedEvent: RCTDirectEventBlock?
|
|
6
7
|
var onAdClickedEvent: RCTDirectEventBlock?
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
|
-
private enum
|
|
4
|
+
private enum DaroRNBannerLoadRequest: Equatable {
|
|
5
5
|
case automatic
|
|
6
6
|
case explicit
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
@objc(
|
|
10
|
-
final class
|
|
9
|
+
@objc(DaroRNAdBannerView)
|
|
10
|
+
final class DaroRNAdBannerView: UIView {
|
|
11
11
|
|
|
12
12
|
var adBannerView: DaroAdBannerView?
|
|
13
|
-
private let eventSink =
|
|
13
|
+
private let eventSink = DaroRNAdEventSink()
|
|
14
14
|
private var hasRequestedInitialLoad = false
|
|
15
|
-
private var pendingLoadRequest:
|
|
15
|
+
private var pendingLoadRequest: DaroRNBannerLoadRequest?
|
|
16
16
|
|
|
17
17
|
@objc var adUnitId: String?
|
|
18
|
-
@objc var adFormat: String =
|
|
18
|
+
@objc var adFormat: String = DaroRNModule.Constants.bannerAdFormatLabel.value
|
|
19
19
|
@objc var loadOnMount: Bool = true
|
|
20
20
|
@objc var isVisible: Bool = true {
|
|
21
21
|
didSet {
|
|
@@ -57,7 +57,7 @@ final class DaroMAdBannerView: UIView {
|
|
|
57
57
|
guard let changedProps, changedProps.isEmpty == false else { return }
|
|
58
58
|
guard let adUnitId, adUnitId.isEmpty == false else {
|
|
59
59
|
if changedProps.contains("adUnitId") {
|
|
60
|
-
|
|
60
|
+
DaroRNModule.logger.warning("AdUnitId is required")
|
|
61
61
|
}
|
|
62
62
|
return
|
|
63
63
|
}
|
|
@@ -75,13 +75,13 @@ final class DaroMAdBannerView: UIView {
|
|
|
75
75
|
func prepareForReuse() {
|
|
76
76
|
resetAdState()
|
|
77
77
|
adUnitId = nil
|
|
78
|
-
adFormat =
|
|
78
|
+
adFormat = DaroRNModule.Constants.bannerAdFormatLabel.value
|
|
79
79
|
loadOnMount = true
|
|
80
80
|
isVisible = true
|
|
81
81
|
isHidden = false
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
private func requestLoad(_ request:
|
|
84
|
+
private func requestLoad(_ request: DaroRNBannerLoadRequest) {
|
|
85
85
|
initialize()
|
|
86
86
|
|
|
87
87
|
guard let adBannerView else { return }
|
|
@@ -101,11 +101,11 @@ final class DaroMAdBannerView: UIView {
|
|
|
101
101
|
return
|
|
102
102
|
}
|
|
103
103
|
guard let adUnitId, adUnitId.isEmpty == false else {
|
|
104
|
-
|
|
104
|
+
DaroRNModule.logger.warning("AdUnitId is required")
|
|
105
105
|
return
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
let bannerSize = adFormat ==
|
|
108
|
+
let bannerSize = adFormat == DaroRNModule.Constants.bannerAdFormatLabel.value ? DaroAdBannerSize.banner : DaroAdBannerSize.MREC
|
|
109
109
|
let adUnit = DaroAdUnit(unitId: adUnitId)
|
|
110
110
|
let adBannerView = DaroAdBannerView(unit: adUnit, bannerSize: bannerSize, autoLoad: false)
|
|
111
111
|
setupBannerListener(for: adBannerView)
|
package/ios/Shared/{DaroMNativeAdLoadCoordinator.swift → DaroRNNativeAdLoadCoordinator.swift}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
|
|
3
|
-
enum
|
|
3
|
+
enum DaroRNNativeAdLoadRequest: Equatable {
|
|
4
4
|
case automatic
|
|
5
5
|
case explicit
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
final class
|
|
9
|
-
private var pendingRequest:
|
|
8
|
+
final class DaroRNNativeAdLoadCoordinator {
|
|
9
|
+
private var pendingRequest: DaroRNNativeAdLoadRequest?
|
|
10
10
|
private var hasConsumedInitialLoad = false
|
|
11
11
|
|
|
12
12
|
var hasPendingLoad: Bool {
|
|
@@ -27,7 +27,7 @@ final class DaroMNativeAdLoadCoordinator {
|
|
|
27
27
|
pendingRequest = nil
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
func consumePendingLoad(loadOnMount: Bool) ->
|
|
30
|
+
func consumePendingLoad(loadOnMount: Bool) -> DaroRNNativeAdLoadRequest? {
|
|
31
31
|
guard let pendingRequest else { return nil }
|
|
32
32
|
|
|
33
33
|
if pendingRequest == .automatic {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
|
-
@objc(
|
|
5
|
-
final class
|
|
4
|
+
@objc(RNDaroRNNativeAdView)
|
|
5
|
+
final class RNDaroRNNativeAdView: UIView, DaroRNNativeAdRenderDelegate {
|
|
6
6
|
|
|
7
7
|
private static let assetLoadRetryDelay: TimeInterval = 0.05
|
|
8
8
|
private static let maxAssetLoadRetryCount = 40
|
|
9
9
|
|
|
10
|
-
var _internalAdView:
|
|
10
|
+
var _internalAdView: DaroRNBridgeNativeAdView?
|
|
11
11
|
private var pinnedConstraints: [ObjectIdentifier: [NSLayoutConstraint]] = [:]
|
|
12
12
|
private var pendingLoadWorkItem: DispatchWorkItem?
|
|
13
|
-
private let loadCoordinator =
|
|
14
|
-
private var defaultAssetResolver:
|
|
15
|
-
private var assetResolver:
|
|
16
|
-
private let eventSink =
|
|
13
|
+
private let loadCoordinator = DaroRNNativeAdLoadCoordinator()
|
|
14
|
+
private var defaultAssetResolver: DaroRNNativeAssetResolving?
|
|
15
|
+
private var assetResolver: DaroRNNativeAssetResolving?
|
|
16
|
+
private let eventSink = DaroRNAdEventSink()
|
|
17
17
|
var adUnit: DaroAdUnit
|
|
18
18
|
|
|
19
19
|
@objc var adUnitId: String?
|
|
@@ -70,11 +70,11 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
70
70
|
}
|
|
71
71
|
@objc var adChoicesPosition: String?
|
|
72
72
|
|
|
73
|
-
var _internalTitleLabel: UILabel =
|
|
74
|
-
var _internalBodyLabel: UILabel =
|
|
75
|
-
var _internalMediaView: UIView =
|
|
76
|
-
var _internalIconImageView: UIImageView =
|
|
77
|
-
var _internalFakeCTAButton: UIButton =
|
|
73
|
+
var _internalTitleLabel: UILabel = RNDaroRNNativeAdView.makeTitleLabel()
|
|
74
|
+
var _internalBodyLabel: UILabel = RNDaroRNNativeAdView.makeBodyLabel()
|
|
75
|
+
var _internalMediaView: UIView = RNDaroRNNativeAdView.makeMediaView()
|
|
76
|
+
var _internalIconImageView: UIImageView = RNDaroRNNativeAdView.makeIconImageView()
|
|
77
|
+
var _internalFakeCTAButton: UIButton = RNDaroRNNativeAdView.makeFakeCTAButton()
|
|
78
78
|
|
|
79
79
|
private static func makeTitleLabel() -> UILabel {
|
|
80
80
|
let label = UILabel()
|
|
@@ -112,6 +112,10 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
112
112
|
return button
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
@objc var onNativeAdAssetLoadedEvent: RCTDirectEventBlock? {
|
|
116
|
+
get { eventSink.onNativeAdAssetLoadedEvent }
|
|
117
|
+
set { eventSink.onNativeAdAssetLoadedEvent = newValue }
|
|
118
|
+
}
|
|
115
119
|
@objc var onAdLoadedEvent: RCTDirectEventBlock? {
|
|
116
120
|
get { eventSink.onAdLoadedEvent }
|
|
117
121
|
set { eventSink.onAdLoadedEvent = newValue }
|
|
@@ -138,7 +142,7 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
138
142
|
return tag
|
|
139
143
|
}
|
|
140
144
|
|
|
141
|
-
convenience init(assetResolver:
|
|
145
|
+
convenience init(assetResolver: DaroRNNativeAssetResolving?) {
|
|
142
146
|
self.init()
|
|
143
147
|
self.defaultAssetResolver = assetResolver
|
|
144
148
|
self.assetResolver = assetResolver
|
|
@@ -167,12 +171,12 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
167
171
|
guard changedProps.isEmpty == false else { return }
|
|
168
172
|
guard let adUnitId, adUnitId.isEmpty == false else {
|
|
169
173
|
if changedProps.contains("adUnitId") {
|
|
170
|
-
|
|
174
|
+
DaroRNModule.logger.warning("[native-ad] AdUnitId is required")
|
|
171
175
|
}
|
|
172
176
|
return
|
|
173
177
|
}
|
|
174
178
|
loadCoordinator.cancelAutomaticLoadIfNeeded(loadOnMount: loadOnMount)
|
|
175
|
-
|
|
179
|
+
DaroRNModule.logger.info("[native-ad] \(#function): \(changedProps)")
|
|
176
180
|
if !isAdUnitIdSet {
|
|
177
181
|
isAdUnitIdSet = true
|
|
178
182
|
makeAdViews(unitId: adUnitId)
|
|
@@ -244,7 +248,7 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
244
248
|
|
|
245
249
|
private func retryPendingLoad(retryCount: Int) {
|
|
246
250
|
guard retryCount < Self.maxAssetLoadRetryCount else {
|
|
247
|
-
|
|
251
|
+
DaroRNModule.logger.warning("[native-ad] Asset views were not ready before load request")
|
|
248
252
|
pendingLoadWorkItem = nil
|
|
249
253
|
return
|
|
250
254
|
}
|
|
@@ -284,7 +288,7 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
284
288
|
|
|
285
289
|
private func makeAdViews(unitId: String) {
|
|
286
290
|
self.adUnit = DaroAdUnit(unitId: unitId)
|
|
287
|
-
let native =
|
|
291
|
+
let native = DaroRNBridgeNativeAdView(
|
|
288
292
|
unit: adUnit,
|
|
289
293
|
preferredAdChoicesPosition: preferredAdChoicesPosition
|
|
290
294
|
)
|
|
@@ -299,6 +303,9 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
299
303
|
}
|
|
300
304
|
pin(native, to: self)
|
|
301
305
|
|
|
306
|
+
self._internalAdView?.listener.onNativeAdAssetLoaded = { [weak self] assetTypes in
|
|
307
|
+
self?.eventSink.onNativeAdAssetLoadedEvent?(["assetTypes": assetTypes.map(\.rawValue)])
|
|
308
|
+
}
|
|
302
309
|
self._internalAdView?.listener.onAdLoadSuccess = { [weak self] _, adInfo in
|
|
303
310
|
self?.eventSink.emitAdLoaded(adInfo?.toBody)
|
|
304
311
|
}
|
|
@@ -375,7 +382,7 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
375
382
|
@objc(setAssetSearchRootView:)
|
|
376
383
|
func setAssetSearchRootView(_ rootView: UIView?) {
|
|
377
384
|
if let rootView {
|
|
378
|
-
assetResolver =
|
|
385
|
+
assetResolver = DaroRNDescendantNativeAssetResolver(rootView: rootView)
|
|
379
386
|
} else {
|
|
380
387
|
assetResolver = defaultAssetResolver
|
|
381
388
|
}
|
|
@@ -504,6 +511,7 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
504
511
|
pinnedConstraints.values.forEach { NSLayoutConstraint.deactivate($0) }
|
|
505
512
|
pinnedConstraints.removeAll()
|
|
506
513
|
|
|
514
|
+
_internalAdView?.listener.onNativeAdAssetLoaded = nil
|
|
507
515
|
_internalAdView?.listener.onAdLoadSuccess = nil
|
|
508
516
|
_internalAdView?.listener.onAdLoadFail = nil
|
|
509
517
|
_internalAdView?.listener.onAdImpression = nil
|
|
@@ -538,12 +546,12 @@ final class RNDaroMNativeAdView: UIView, DaroMNativeAdRenderDelegate {
|
|
|
538
546
|
}
|
|
539
547
|
}
|
|
540
548
|
|
|
541
|
-
protocol
|
|
549
|
+
protocol DaroRNNativeAdRenderDelegate: AnyObject {
|
|
542
550
|
func renderAd(for nativeAd: DaroAdNative)
|
|
543
551
|
}
|
|
544
552
|
|
|
545
|
-
class
|
|
546
|
-
weak var delegate:
|
|
553
|
+
class DaroRNBridgeNativeAdView: DaroAdNativeView {
|
|
554
|
+
weak var delegate: DaroRNNativeAdRenderDelegate?
|
|
547
555
|
|
|
548
556
|
override func renderAd(for nativeAd: DaroAdNative, loader: any AdNativeLoadable) {
|
|
549
557
|
super.renderAd(for: nativeAd, loader: loader)
|