react-native-daro 1.0.15 → 2.0.0-rc.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 +2 -5
- package/android/build.gradle +17 -14
- package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
- package/android/src/main/java/com/daro/reactnative/DaroRNAdBannerViewManager.kt +105 -0
- package/android/src/main/java/com/daro/reactnative/DaroRNAdNativeViewManager.kt +163 -0
- package/android/src/main/java/com/daro/reactnative/DaroRNModule.kt +376 -0
- package/android/src/main/java/com/daro/reactnative/DaroRNPackage.kt +45 -0
- 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} +22 -11
- 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/{DaroMLightPopupModuleImpl.kt → DaroRNLightPopupModuleImpl.kt} +4 -4
- package/android/src/main/java/com/daro/reactnative/impl/{DaroMRewardedAdModuleImpl.kt → DaroRNRewardedAdModuleImpl.kt} +4 -4
- 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 +20 -7
- package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +123 -0
- package/android/src/main/java/com/daro/reactnative/view/{DaroMAdBannerViewContainer.kt → DaroRNAdBannerViewContainer.kt} +2 -3
- package/android/src/main/java/com/daro/reactnative/view/DaroRNAdNativeViewContainer.kt +623 -0
- package/android/src/newarch/java/com/daro/reactnative/DaroRNModuleSpec.kt +6 -0
- package/android/src/oldarch/java/com/daro/reactnative/DaroRNModuleSpec.kt +119 -0
- package/ios/{DaroMModule+AppOpen.swift → DaroRNModule+AppOpen.swift} +22 -20
- package/ios/DaroRNModule+Consent.swift +88 -0
- package/ios/{DaroMModule+Interstitial.swift → DaroRNModule+Interstitial.swift} +21 -18
- package/ios/{DaroMModule+LightPopup.swift → DaroRNModule+LightPopup.swift} +18 -15
- package/ios/DaroRNModule+Qa.swift +158 -0
- package/ios/{DaroMModule+Rewarded.swift → DaroRNModule+Rewarded.swift} +22 -19
- package/ios/DaroRNModule.mm +88 -0
- package/ios/{DaroMModule.swift → DaroRNModule.swift} +24 -10
- package/ios/Fabric/DaroRNAdBannerComponentView.mm +219 -0
- package/ios/Fabric/DaroRNFabricEventSink.mm +31 -0
- package/ios/Fabric/DaroRNFabricPropApplier.mm +123 -0
- package/ios/Fabric/DaroRNNativeAdComponentView.mm +306 -0
- package/ios/{DaroMAdBannerViewManager.m → Paper/DaroRNAdBannerViewManager.m} +4 -2
- package/ios/Paper/DaroRNAdBannerViewManager.swift +21 -0
- package/ios/{DaroMNativeAdViewManager.m → Paper/DaroRNNativeAdViewManager.m} +3 -2
- package/ios/Paper/DaroRNNativeAdViewManager.swift +22 -0
- package/ios/Shared/DaroMediationDebugger.swift +14 -0
- package/ios/{mediation/admob → Shared}/DaroMediationTypes.swift +1 -0
- package/ios/Shared/DaroRNAdEventSink.swift +24 -0
- package/ios/Shared/DaroRNBannerAdView.swift +188 -0
- package/ios/Shared/DaroRNNativeAdLoadCoordinator.swift +49 -0
- package/ios/Shared/DaroRNNativeAdView.swift +575 -0
- package/ios/Shared/DaroRNNativeAssetResolver.swift +53 -0
- package/lib/commonjs/AdBannerView.js +20 -41
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +45 -12
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/commonjs/DaroRNAdBannerViewNativeComponent.ts +50 -0
- package/lib/commonjs/DaroRNNativeAdViewNativeComponent.ts +65 -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 +150 -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 -42
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +45 -13
- package/lib/module/AppOpenAd.js.map +1 -1
- package/lib/module/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/module/DaroRNAdBannerViewNativeComponent.ts +50 -0
- package/lib/module/DaroRNNativeAdViewNativeComponent.ts +65 -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 +108 -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 +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 +2 -2
- 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/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts +33 -0
- package/lib/typescript/commonjs/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts +43 -0
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.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 +70 -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 +86 -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/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 +2 -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 +2 -2
- 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/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts +33 -0
- package/lib/typescript/module/src/DaroRNAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts +43 -0
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.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 +70 -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 +86 -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/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 +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 +2 -6
- package/plugin/build/index.js +21 -56
- package/plugin/build/withAndroid.d.ts +2 -6
- package/plugin/build/withAndroid.js +123 -83
- package/plugin/build/withIos.d.ts +2 -6
- package/plugin/build/withIos.js +37 -34
- package/react-native-daro.podspec +4 -2
- package/src/AdBannerView.tsx +24 -63
- package/src/AppOpenAd.ts +48 -17
- package/src/DaroMediaViewNativeComponent.ts +9 -0
- package/src/DaroRNAdBannerViewNativeComponent.ts +50 -0
- package/src/DaroRNNativeAdViewNativeComponent.ts +65 -0
- package/src/EventEmitter.ts +4 -5
- package/src/InterstitialAd.ts +8 -10
- package/src/LightPopupAd.ts +11 -12
- package/src/NativeDaroModule.ts +106 -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 +157 -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/AdInfo.ts +17 -0
- package/src/types/AdProps.ts +0 -2
- package/src/types/NativeAdViewProps.ts +7 -0
- package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +0 -23
- package/android/src/main/java/com/daro/reactnative/DaroMAdBannerViewManager.kt +0 -132
- package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +0 -136
- package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +0 -202
- package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +0 -21
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +0 -375
- package/ios/DaroMAdBannerViewManager.swift +0 -91
- package/ios/DaroMModule.mm +0 -45
- package/ios/DaroMNativeAdViewManager.swift +0 -291
- 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/types/DaroMMobileAds.d.ts +0 -6
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.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
|
@@ -0,0 +1,306 @@
|
|
|
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 onAdLoadedEvent = ^(NSDictionary *body) {
|
|
82
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
83
|
+
if (!strongSelf) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
88
|
+
if (!eventEmitter) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
93
|
+
eventEmitter->onAdLoadedEvent({
|
|
94
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
95
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
96
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
97
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
98
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
99
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
RCTDirectEventBlock onAdLoadFailedEvent = ^(NSDictionary *body) {
|
|
104
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
105
|
+
if (!strongSelf) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
110
|
+
if (!eventEmitter) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
115
|
+
eventEmitter->onAdLoadFailedEvent({
|
|
116
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
117
|
+
.code = DaroRNFabricEventInt(eventBody, @"code"),
|
|
118
|
+
.message = DaroRNFabricEventString(eventBody, @"message"),
|
|
119
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
RCTDirectEventBlock onAdClickedEvent = ^(NSDictionary *body) {
|
|
124
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
125
|
+
if (!strongSelf) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
130
|
+
if (!eventEmitter) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
135
|
+
eventEmitter->onAdClickedEvent({
|
|
136
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
137
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
138
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
139
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
140
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
141
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
RCTDirectEventBlock onAdImpressionRecordedEvent = ^(NSDictionary *body) {
|
|
146
|
+
DaroRNNativeAdViewComponentView *strongSelf = weakSelf;
|
|
147
|
+
if (!strongSelf) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNNativeAdViewEventEmitter>(strongSelf->_eventEmitter);
|
|
152
|
+
if (!eventEmitter) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
157
|
+
eventEmitter->onAdImpressionRecordedEvent({
|
|
158
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
159
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
160
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
161
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
162
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
163
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadedEvent", onAdLoadedEvent);
|
|
168
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadFailedEvent", onAdLoadFailedEvent);
|
|
169
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdClickedEvent", onAdClickedEvent);
|
|
170
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdImpressionRecordedEvent", onAdImpressionRecordedEvent);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
174
|
+
{
|
|
175
|
+
return concreteComponentDescriptorProvider<DaroRNNativeAdViewComponentDescriptor>();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
179
|
+
{
|
|
180
|
+
const auto &oldComponentProps = *std::static_pointer_cast<const DaroRNNativeAdViewProps>(_props);
|
|
181
|
+
const auto &newComponentProps = *std::static_pointer_cast<const DaroRNNativeAdViewProps>(props);
|
|
182
|
+
NSMutableArray<NSString *> *changedProps = [NSMutableArray new];
|
|
183
|
+
|
|
184
|
+
if (oldComponentProps.adUnitId != newComponentProps.adUnitId) {
|
|
185
|
+
DaroRNFabricSetValue(_nativeAdView, @"adUnitId", DaroRNFabricNSStringFromStdString(newComponentProps.adUnitId));
|
|
186
|
+
[changedProps addObject:@"adUnitId"];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (oldComponentProps.loadOnMount != newComponentProps.loadOnMount) {
|
|
190
|
+
DaroRNFabricSetValue(_nativeAdView, @"loadOnMount", @(newComponentProps.loadOnMount));
|
|
191
|
+
[changedProps addObject:@"loadOnMount"];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (oldComponentProps.adChoicesPosition != newComponentProps.adChoicesPosition) {
|
|
195
|
+
DaroRNFabricSetValue(
|
|
196
|
+
_nativeAdView, @"adChoicesPosition", DaroRNFabricAdChoicesPositionString(newComponentProps.adChoicesPosition));
|
|
197
|
+
[changedProps addObject:@"adChoicesPosition"];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (oldComponentProps.titleView != newComponentProps.titleView) {
|
|
201
|
+
DaroRNFabricSetValue(_nativeAdView, @"titleView", @(newComponentProps.titleView));
|
|
202
|
+
[changedProps addObject:@"titleView"];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (oldComponentProps.bodyView != newComponentProps.bodyView) {
|
|
206
|
+
DaroRNFabricSetValue(_nativeAdView, @"bodyView", @(newComponentProps.bodyView));
|
|
207
|
+
[changedProps addObject:@"bodyView"];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (oldComponentProps.callToActionView != newComponentProps.callToActionView) {
|
|
211
|
+
DaroRNFabricSetValue(_nativeAdView, @"callToActionView", @(newComponentProps.callToActionView));
|
|
212
|
+
[changedProps addObject:@"callToActionView"];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (oldComponentProps.iconView != newComponentProps.iconView) {
|
|
216
|
+
DaroRNFabricSetValue(_nativeAdView, @"iconView", @(newComponentProps.iconView));
|
|
217
|
+
[changedProps addObject:@"iconView"];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (oldComponentProps.mediaView != newComponentProps.mediaView) {
|
|
221
|
+
DaroRNFabricSetValue(_nativeAdView, @"mediaView", @(newComponentProps.mediaView));
|
|
222
|
+
[changedProps addObject:@"mediaView"];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (oldComponentProps.titleViewStyleProps != newComponentProps.titleViewStyleProps) {
|
|
226
|
+
DaroRNFabricSetValue(_nativeAdView, @"titleViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.titleViewStyleProps));
|
|
227
|
+
[changedProps addObject:@"titleViewStyleProps"];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (oldComponentProps.bodyViewStyleProps != newComponentProps.bodyViewStyleProps) {
|
|
231
|
+
DaroRNFabricSetValue(_nativeAdView, @"bodyViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.bodyViewStyleProps));
|
|
232
|
+
[changedProps addObject:@"bodyViewStyleProps"];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (oldComponentProps.callToActionViewStyleProps != newComponentProps.callToActionViewStyleProps) {
|
|
236
|
+
DaroRNFabricSetValue(
|
|
237
|
+
_nativeAdView, @"callToActionViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.callToActionViewStyleProps));
|
|
238
|
+
[changedProps addObject:@"callToActionViewStyleProps"];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (oldComponentProps.iconViewStyleProps != newComponentProps.iconViewStyleProps) {
|
|
242
|
+
DaroRNFabricSetValue(_nativeAdView, @"iconViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.iconViewStyleProps));
|
|
243
|
+
[changedProps addObject:@"iconViewStyleProps"];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (oldComponentProps.mediaViewStyleProps != newComponentProps.mediaViewStyleProps) {
|
|
247
|
+
DaroRNFabricSetValue(_nativeAdView, @"mediaViewStyleProps", DaroRNFabricIdFromDynamic(newComponentProps.mediaViewStyleProps));
|
|
248
|
+
[changedProps addObject:@"mediaViewStyleProps"];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
[super updateProps:props oldProps:oldProps];
|
|
252
|
+
|
|
253
|
+
DaroRNFabricPerformSelectorWithObject(_nativeAdView, NSSelectorFromString(@"applyReactProps:"), changedProps);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
257
|
+
{
|
|
258
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
259
|
+
_nativeAdView.frame = self.bounds;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
263
|
+
{
|
|
264
|
+
DaroRNFabricPerformSelectorWithTwoObjects(
|
|
265
|
+
_nativeAdView, NSSelectorFromString(@"insertMountedSubview:atIndex:"), childComponentView, @(index));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
269
|
+
{
|
|
270
|
+
[childComponentView removeFromSuperview];
|
|
271
|
+
DaroRNFabricPerformSelector(_nativeAdView, NSSelectorFromString(@"refreshMountedAssetViews"));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
- (void)loadAd
|
|
275
|
+
{
|
|
276
|
+
DaroRNFabricPerformSelector(_nativeAdView, NSSelectorFromString(@"loadAd"));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
280
|
+
{
|
|
281
|
+
RCTDaroRNNativeAdViewHandleCommand(self, commandName, args);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
- (void)prepareForRecycle
|
|
285
|
+
{
|
|
286
|
+
[super prepareForRecycle];
|
|
287
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadedEvent", nil);
|
|
288
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdLoadFailedEvent", nil);
|
|
289
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdClickedEvent", nil);
|
|
290
|
+
DaroRNFabricSetValue(_nativeAdView, @"onAdImpressionRecordedEvent", nil);
|
|
291
|
+
DaroRNFabricPerformSelectorWithObject(_nativeAdView, NSSelectorFromString(@"setAssetSearchRootView:"), nil);
|
|
292
|
+
DaroRNFabricPerformSelector(_nativeAdView, NSSelectorFromString(@"prepareForReuse"));
|
|
293
|
+
DaroRNFabricPerformSelectorWithObject(_nativeAdView, NSSelectorFromString(@"setAssetSearchRootView:"), _nativeAdView);
|
|
294
|
+
[self installEventHandlers];
|
|
295
|
+
static const auto defaultProps = std::make_shared<const DaroRNNativeAdViewProps>();
|
|
296
|
+
_props = defaultProps;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@end
|
|
300
|
+
|
|
301
|
+
Class<RCTComponentViewProtocol> DaroRNNativeAdViewCls(void)
|
|
302
|
+
{
|
|
303
|
+
return DaroRNNativeAdViewComponentView.class;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
#endif
|
|
@@ -1,15 +1,17 @@
|
|
|
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)
|
|
7
|
+
RCT_EXPORT_VIEW_PROPERTY(loadOnMount, BOOL)
|
|
8
|
+
RCT_EXPORT_VIEW_PROPERTY(isVisible, BOOL)
|
|
7
9
|
|
|
8
10
|
RCT_EXPORT_VIEW_PROPERTY(onAdLoadedEvent, RCTDirectEventBlock)
|
|
9
11
|
RCT_EXPORT_VIEW_PROPERTY(onAdLoadFailedEvent, RCTDirectEventBlock)
|
|
10
12
|
RCT_EXPORT_VIEW_PROPERTY(onAdClickedEvent, RCTDirectEventBlock)
|
|
11
13
|
RCT_EXPORT_VIEW_PROPERTY(onAdImpressionRecordedEvent, RCTDirectEventBlock)
|
|
12
14
|
|
|
13
|
-
RCT_EXTERN_METHOD(loadAd)
|
|
15
|
+
RCT_EXTERN_METHOD(loadAd : (nonnull NSNumber *)viewTag)
|
|
14
16
|
|
|
15
17
|
@end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React
|
|
2
|
+
|
|
3
|
+
@objc(DaroRNAdBannerViewManager)
|
|
4
|
+
class DaroRNAdBannerViewManager: RCTViewManager {
|
|
5
|
+
override func view() -> DaroRNAdBannerView {
|
|
6
|
+
DaroRNAdBannerView()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
10
|
+
false
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc(loadAd:)
|
|
14
|
+
func loadAd(viewTag: NSNumber) {
|
|
15
|
+
bridge?.uiManager.addUIBlock({ _, viewRegistry in
|
|
16
|
+
if let view = viewRegistry?[viewTag] as? DaroRNAdBannerView {
|
|
17
|
+
view.loadAd()
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
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
|
+
RCT_EXPORT_VIEW_PROPERTY(loadOnMount, BOOL)
|
|
7
|
+
RCT_EXPORT_VIEW_PROPERTY(adChoicesPosition, NSString)
|
|
6
8
|
|
|
7
9
|
RCT_EXPORT_VIEW_PROPERTY(titleView, NSNumber)
|
|
8
10
|
RCT_EXPORT_VIEW_PROPERTY(bodyView, NSNumber)
|
|
9
11
|
RCT_EXPORT_VIEW_PROPERTY(callToActionView, NSNumber)
|
|
10
12
|
RCT_EXPORT_VIEW_PROPERTY(iconView, NSNumber)
|
|
11
|
-
RCT_EXPORT_VIEW_PROPERTY(optionsView, NSNumber)
|
|
12
13
|
RCT_EXPORT_VIEW_PROPERTY(mediaView, NSNumber)
|
|
13
14
|
|
|
14
15
|
RCT_EXPORT_VIEW_PROPERTY(titleViewStyleProps, NSDictionary)
|
|
@@ -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
|
+
}
|
|
@@ -6,6 +6,7 @@ internal typealias DaroAdFormat = Daro.DaroAdFormat
|
|
|
6
6
|
internal typealias DaroAdInfo = Daro.DaroAdInfo
|
|
7
7
|
internal typealias DaroAdNative = Daro.DaroAdNative
|
|
8
8
|
internal typealias DaroAdNativeView = Daro.DaroAdNativeView
|
|
9
|
+
internal typealias DaroAdChoicesPosition = Daro.DaroAdChoicesPosition
|
|
9
10
|
internal typealias DaroAdUnit = Daro.DaroAdUnit
|
|
10
11
|
internal typealias DaroAds = Daro.DaroAds
|
|
11
12
|
internal typealias DaroAppOpenAd = Daro.DaroAppOpenAd
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React
|
|
2
|
+
|
|
3
|
+
final class DaroRNAdEventSink {
|
|
4
|
+
var onAdLoadedEvent: RCTDirectEventBlock?
|
|
5
|
+
var onAdLoadFailedEvent: RCTDirectEventBlock?
|
|
6
|
+
var onAdClickedEvent: RCTDirectEventBlock?
|
|
7
|
+
var onAdImpressionRecordedEvent: RCTDirectEventBlock?
|
|
8
|
+
|
|
9
|
+
func emitAdLoaded(_ body: [AnyHashable: Any]?) {
|
|
10
|
+
onAdLoadedEvent?(body)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
func emitAdLoadFailed(_ body: [AnyHashable: Any]?) {
|
|
14
|
+
onAdLoadFailedEvent?(body)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func emitAdClicked(_ body: [AnyHashable: Any]?) {
|
|
18
|
+
onAdClickedEvent?(body)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func emitAdImpressionRecorded(_ body: [AnyHashable: Any]?) {
|
|
22
|
+
onAdImpressionRecordedEvent?(body)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import React
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
private enum DaroRNBannerLoadRequest: Equatable {
|
|
5
|
+
case automatic
|
|
6
|
+
case explicit
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@objc(DaroRNAdBannerView)
|
|
10
|
+
final class DaroRNAdBannerView: UIView {
|
|
11
|
+
|
|
12
|
+
var adBannerView: DaroAdBannerView?
|
|
13
|
+
private let eventSink = DaroRNAdEventSink()
|
|
14
|
+
private var hasRequestedInitialLoad = false
|
|
15
|
+
private var pendingLoadRequest: DaroRNBannerLoadRequest?
|
|
16
|
+
|
|
17
|
+
@objc var adUnitId: String?
|
|
18
|
+
@objc var adFormat: String = DaroRNModule.Constants.bannerAdFormatLabel.value
|
|
19
|
+
@objc var loadOnMount: Bool = true
|
|
20
|
+
@objc var isVisible: Bool = true {
|
|
21
|
+
didSet {
|
|
22
|
+
setAdVisibility(isVisible)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@objc var onAdLoadedEvent: RCTDirectEventBlock? {
|
|
27
|
+
get { eventSink.onAdLoadedEvent }
|
|
28
|
+
set { eventSink.onAdLoadedEvent = newValue }
|
|
29
|
+
}
|
|
30
|
+
@objc var onAdLoadFailedEvent: RCTDirectEventBlock? {
|
|
31
|
+
get { eventSink.onAdLoadFailedEvent }
|
|
32
|
+
set { eventSink.onAdLoadFailedEvent = newValue }
|
|
33
|
+
}
|
|
34
|
+
@objc var onAdClickedEvent: RCTDirectEventBlock? {
|
|
35
|
+
get { eventSink.onAdClickedEvent }
|
|
36
|
+
set { eventSink.onAdClickedEvent = newValue }
|
|
37
|
+
}
|
|
38
|
+
@objc var onAdImpressionRecordedEvent: RCTDirectEventBlock? {
|
|
39
|
+
get { eventSink.onAdImpressionRecordedEvent }
|
|
40
|
+
set { eventSink.onAdImpressionRecordedEvent = newValue }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
init() {
|
|
44
|
+
super.init(frame: CGRect.zero)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
required init?(coder: NSCoder) {
|
|
48
|
+
fatalError("init(coder:) has not been implemented")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override func didSetProps(_ changedProps: [String]!) {
|
|
52
|
+
applyReactProps(changedProps)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@objc(applyReactProps:)
|
|
56
|
+
func applyReactProps(_ changedProps: [String]!) {
|
|
57
|
+
guard let changedProps, changedProps.isEmpty == false else { return }
|
|
58
|
+
guard let adUnitId, adUnitId.isEmpty == false else {
|
|
59
|
+
if changedProps.contains("adUnitId") {
|
|
60
|
+
DaroRNModule.logger.warning("AdUnitId is required")
|
|
61
|
+
}
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
cancelAutomaticLoadIfNeeded(changedProps)
|
|
65
|
+
initialize()
|
|
66
|
+
requestInitialLoadIfNeeded()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@objc
|
|
70
|
+
func loadAd() {
|
|
71
|
+
requestLoad(.explicit)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@objc(prepareForReuse)
|
|
75
|
+
func prepareForReuse() {
|
|
76
|
+
resetAdState()
|
|
77
|
+
adUnitId = nil
|
|
78
|
+
adFormat = DaroRNModule.Constants.bannerAdFormatLabel.value
|
|
79
|
+
loadOnMount = true
|
|
80
|
+
isVisible = true
|
|
81
|
+
isHidden = false
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private func requestLoad(_ request: DaroRNBannerLoadRequest) {
|
|
85
|
+
initialize()
|
|
86
|
+
|
|
87
|
+
guard let adBannerView else { return }
|
|
88
|
+
guard isVisible else {
|
|
89
|
+
pendingLoadRequest = request
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
pendingLoadRequest = nil
|
|
94
|
+
hasRequestedInitialLoad = true
|
|
95
|
+
adBannerView.loadAd()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@objc(initialize)
|
|
99
|
+
func initialize() {
|
|
100
|
+
guard adBannerView == nil else {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
guard let adUnitId, adUnitId.isEmpty == false else {
|
|
104
|
+
DaroRNModule.logger.warning("AdUnitId is required")
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let bannerSize = adFormat == DaroRNModule.Constants.bannerAdFormatLabel.value ? DaroAdBannerSize.banner : DaroAdBannerSize.MREC
|
|
109
|
+
let adUnit = DaroAdUnit(unitId: adUnitId)
|
|
110
|
+
let adBannerView = DaroAdBannerView(unit: adUnit, bannerSize: bannerSize, autoLoad: false)
|
|
111
|
+
setupBannerListener(for: adBannerView)
|
|
112
|
+
|
|
113
|
+
adBannerView.isHidden = !isVisible
|
|
114
|
+
adBannerView.translatesAutoresizingMaskIntoConstraints = false
|
|
115
|
+
addSubview(adBannerView)
|
|
116
|
+
self.adBannerView = adBannerView
|
|
117
|
+
|
|
118
|
+
NSLayoutConstraint.activate([
|
|
119
|
+
adBannerView.widthAnchor.constraint(equalToConstant: bannerSize.width),
|
|
120
|
+
adBannerView.heightAnchor.constraint(equalToConstant: bannerSize.height),
|
|
121
|
+
adBannerView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
|
|
122
|
+
adBannerView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
|
|
123
|
+
])
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private func requestInitialLoadIfNeeded() {
|
|
127
|
+
guard loadOnMount, !hasRequestedInitialLoad, pendingLoadRequest == nil else { return }
|
|
128
|
+
requestLoad(.automatic)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private func loadPendingAdIfReady() {
|
|
132
|
+
guard let pendingLoadRequest, isVisible else { return }
|
|
133
|
+
guard pendingLoadRequest != .automatic || loadOnMount else {
|
|
134
|
+
self.pendingLoadRequest = nil
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
requestLoad(pendingLoadRequest)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private func cancelAutomaticLoadIfNeeded(_ changedProps: [String]) {
|
|
142
|
+
guard changedProps.contains("loadOnMount"),
|
|
143
|
+
!loadOnMount,
|
|
144
|
+
pendingLoadRequest == .automatic else {
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
pendingLoadRequest = nil
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private func setAdVisibility(_ visible: Bool) {
|
|
152
|
+
isHidden = !visible
|
|
153
|
+
adBannerView?.isHidden = !visible
|
|
154
|
+
|
|
155
|
+
if visible {
|
|
156
|
+
loadPendingAdIfReady()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private func setupBannerListener(for bannerView: DaroAdBannerView) {
|
|
161
|
+
bannerView.listener.onAdLoadSuccess = { [weak self] _, adInfo in
|
|
162
|
+
self?.eventSink.emitAdLoaded(adInfo?.toBody)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
bannerView.listener.onAdLoadFail = { [weak self] error in
|
|
166
|
+
self?.eventSink.emitAdLoadFailed(error.toBody)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
bannerView.listener.onAdImpression = { [weak self] adInfo in
|
|
170
|
+
self?.eventSink.emitAdImpressionRecorded(adInfo?.toBody)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
bannerView.listener.onAdClicked = { [weak self] adInfo in
|
|
174
|
+
self?.eventSink.emitAdClicked(adInfo?.toBody)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private func resetAdState() {
|
|
179
|
+
pendingLoadRequest = nil
|
|
180
|
+
hasRequestedInitialLoad = false
|
|
181
|
+
adBannerView?.listener.onAdLoadSuccess = nil
|
|
182
|
+
adBannerView?.listener.onAdLoadFail = nil
|
|
183
|
+
adBannerView?.listener.onAdImpression = nil
|
|
184
|
+
adBannerView?.listener.onAdClicked = nil
|
|
185
|
+
adBannerView?.removeFromSuperview()
|
|
186
|
+
adBannerView = nil
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
enum DaroRNNativeAdLoadRequest: Equatable {
|
|
4
|
+
case automatic
|
|
5
|
+
case explicit
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
final class DaroRNNativeAdLoadCoordinator {
|
|
9
|
+
private var pendingRequest: DaroRNNativeAdLoadRequest?
|
|
10
|
+
private var hasConsumedInitialLoad = false
|
|
11
|
+
|
|
12
|
+
var hasPendingLoad: Bool {
|
|
13
|
+
pendingRequest != nil
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
func requestAutomaticLoad(loadOnMount: Bool) {
|
|
17
|
+
guard loadOnMount, !hasConsumedInitialLoad, pendingRequest == nil else { return }
|
|
18
|
+
pendingRequest = .automatic
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func requestExplicitLoad() {
|
|
22
|
+
pendingRequest = .explicit
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
func cancelAutomaticLoadIfNeeded(loadOnMount: Bool) {
|
|
26
|
+
guard !loadOnMount, pendingRequest == .automatic else { return }
|
|
27
|
+
pendingRequest = nil
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func consumePendingLoad(loadOnMount: Bool) -> DaroRNNativeAdLoadRequest? {
|
|
31
|
+
guard let pendingRequest else { return nil }
|
|
32
|
+
|
|
33
|
+
if pendingRequest == .automatic {
|
|
34
|
+
guard loadOnMount, !hasConsumedInitialLoad else {
|
|
35
|
+
self.pendingRequest = nil
|
|
36
|
+
return nil
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
self.pendingRequest = nil
|
|
41
|
+
hasConsumedInitialLoad = true
|
|
42
|
+
return pendingRequest
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func reset() {
|
|
46
|
+
pendingRequest = nil
|
|
47
|
+
hasConsumedInitialLoad = false
|
|
48
|
+
}
|
|
49
|
+
}
|