react-native-daro 1.0.16 → 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 +6 -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 +376 -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} +6 -6
- 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 +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} +3 -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} +32 -3
- 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/{DaroMModule+LightPopup.swift → DaroRNModule+LightPopup.swift} +2 -2
- package/ios/DaroRNModule+Qa.swift +158 -0
- package/ios/{DaroMModule+Rewarded.swift → DaroRNModule+Rewarded.swift} +10 -10
- package/ios/{DaroMModule.mm → DaroRNModule.mm} +19 -4
- package/ios/{DaroMModule.swift → DaroRNModule.swift} +20 -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 +306 -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} +1 -1
- package/ios/Paper/DaroRNNativeAdViewManager.swift +22 -0
- package/ios/Shared/DaroMediationDebugger.swift +14 -0
- package/ios/Shared/{DaroMAdEventSink.swift → DaroRNAdEventSink.swift} +1 -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} +21 -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} +5 -2
- package/lib/commonjs/NativeDaroModule.js +1 -1
- package/lib/commonjs/NativeDaroModule.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 +3 -3
- package/lib/commonjs/nativeAd/NativeAdView.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} +5 -2
- package/lib/module/NativeDaroModule.js +1 -1
- package/lib/module/NativeDaroModule.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 +1 -1
- package/lib/module/nativeAd/NativeAdView.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} +3 -2
- package/lib/typescript/commonjs/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +10 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.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/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/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} +3 -2
- package/lib/typescript/module/src/DaroRNNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeDaroModule.d.ts +10 -1
- package/lib/typescript/module/src/NativeDaroModule.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/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/package.json +3 -3
- 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} +5 -2
- package/src/NativeDaroModule.ts +17 -2
- package/src/index.tsx +136 -0
- package/src/nativeAd/NativeAdView.tsx +1 -1
- package/src/types/AdInfo.ts +17 -0
- package/src/types/AdProps.ts +0 -2
- 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/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,158 @@
|
|
|
1
|
+
import AppLovinSDK
|
|
2
|
+
import Daro
|
|
3
|
+
import Dispatch
|
|
4
|
+
import GoogleMobileAds
|
|
5
|
+
import React
|
|
6
|
+
|
|
7
|
+
/// Ad Inspector 제시 판정 상태 — **메인 큐에서만 만진다.**
|
|
8
|
+
///
|
|
9
|
+
/// 값 타입 로컬을 escaping 클로저가 캡처하면 콜백 큐에 따라 읽기·쓰기가 겹칠 수 있어
|
|
10
|
+
/// promise 가 두 번 settle 될 위험이 있다. 참조 타입으로 두고 접근을 메인 큐로 모은다.
|
|
11
|
+
private final class DebuggerPresentation {
|
|
12
|
+
var settled = false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// QA 표면 — 통합 SDK 의 공개 API(mediationStatuses·mediationWeights)는 그대로 브리지하고,
|
|
16
|
+
// SDK 가 갖지 않는 것(서브네트워크 인벤토리·벤더 디버거)은 네이티브 QA 앱들과 같은 축으로
|
|
17
|
+
// 벤더에 직접 묻는다 (DARO-1424).
|
|
18
|
+
extension DaroRNModule {
|
|
19
|
+
|
|
20
|
+
@objc(getSdkVersion:reject:)
|
|
21
|
+
func getSdkVersion(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
22
|
+
// 핀(2.0.0-beta01, 8/19 빌드)에는 @_spi sdkVersion(DARO-1409, 8/21)이 없다.
|
|
23
|
+
// SPI 실린 베타로 핀이 오르면 실제 값으로 교체한다.
|
|
24
|
+
resolve(NSNull())
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@objc(getMediationStatuses:reject:)
|
|
28
|
+
func getMediationStatuses(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
29
|
+
resolve(
|
|
30
|
+
DaroAds.shared.mediationStatuses.map {
|
|
31
|
+
[
|
|
32
|
+
"mediationPlatform": $0.mediationPlatform,
|
|
33
|
+
"isReady": $0.isReady,
|
|
34
|
+
"hasFailed": $0.hasFailed,
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@objc(getMediationWeights:reject:)
|
|
41
|
+
func getMediationWeights(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
42
|
+
if let weights = DaroAds.shared.mediationWeights {
|
|
43
|
+
// 키가 공개 어휘를 따른다 (DARO-1594). SDK 프로퍼티 이름과 같으므로 여기서
|
|
44
|
+
// 매핑하지 않는다 — 매핑을 두면 어휘가 또 바뀔 때 한쪽만 낡는다.
|
|
45
|
+
resolve(["daroa": weights.daroa, "darom": weights.darom])
|
|
46
|
+
} else {
|
|
47
|
+
resolve(NSNull())
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@objc(showMediationDebuggerFor:resolve:reject:)
|
|
52
|
+
func showMediationDebuggerFor(
|
|
53
|
+
mediation: String,
|
|
54
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
55
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
56
|
+
) {
|
|
57
|
+
DispatchQueue.main.async {
|
|
58
|
+
if mediation == "applovin" {
|
|
59
|
+
// ALSdk 초기화 뒤에 불러야 한다 — 전이면 빈 화면이 뜬다 (QA 앱 DebuggerHelper 실측).
|
|
60
|
+
ALSdk.shared().showMediationDebugger()
|
|
61
|
+
resolve(nil)
|
|
62
|
+
} else {
|
|
63
|
+
// **에러를 삼키지 않는다.** 초기화 전이거나 테스트 기기가 아니면 GMA 가 여기로
|
|
64
|
+
// 사유를 준다 — 버리면 화면에는 성공 로그만 남고 검사기는 안 뜬다.
|
|
65
|
+
//
|
|
66
|
+
// 이 콜백 하나가 두 사건을 겸한다: **실패(제시 못 함)** 와 **닫힘(정상 종료)**.
|
|
67
|
+
// 그래서 어느 쪽도 그냥 믿을 수 없다 — 콜백을 기다려 성공을 판정하면 "열렸다"가
|
|
68
|
+
// 검사기를 닫을 때까지(또는 앱을 그대로 죽이면 영영) 안 뜨고, 기다리지 않고 바로
|
|
69
|
+
// 성공 처리하면 **비동기로 오는 실패**(GMA 는 설정을 받아본 뒤에야 거절 사유를
|
|
70
|
+
// 안다)를 놓쳐 성공 로그만 남는다.
|
|
71
|
+
//
|
|
72
|
+
// 그래서 짧은 유예를 둔다. 그 안에 온 콜백은 제시 실패로 보고 reject 하고,
|
|
73
|
+
// 조용하면 떠 있는 것으로 보고 resolve 한다 — 그 뒤에 오는 콜백은 닫힘이다.
|
|
74
|
+
// **모든 판정을 메인 큐에서 한다** — 벤더가 어느 큐로 콜백하든 이중 settle 이
|
|
75
|
+
// 나지 않게(RN 은 두 번 settle 하면 예외를 던진다).
|
|
76
|
+
let state = DebuggerPresentation()
|
|
77
|
+
MobileAds.shared.presentAdInspector(from: nil) { error in
|
|
78
|
+
DispatchQueue.main.async {
|
|
79
|
+
if state.settled {
|
|
80
|
+
if let error {
|
|
81
|
+
Self.logger.error("Ad Inspector 종료 시 에러: \(error.localizedDescription)")
|
|
82
|
+
}
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
state.settled = true
|
|
86
|
+
if let error {
|
|
87
|
+
reject("AD_INSPECTOR_FAILED", error.localizedDescription, error)
|
|
88
|
+
} else {
|
|
89
|
+
// 유예 안에 에러 없이 닫혔다 — 열렸다가 곧장 닫힌 경우다.
|
|
90
|
+
resolve(nil)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
|
95
|
+
guard !state.settled else { return }
|
|
96
|
+
state.settled = true
|
|
97
|
+
resolve(nil)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 주입 결과 판독 — pod install 훅이 Info.plist 에 심은 봉투·파생값 4종을 그대로 돌려준다.
|
|
104
|
+
@objc(getIntegrationKeyInfo:reject:)
|
|
105
|
+
func getIntegrationKeyInfo(resolve: RCTPromiseResolveBlock, reject: RCTPromiseRejectBlock) {
|
|
106
|
+
let keys = [
|
|
107
|
+
"DaroIntegrationKey",
|
|
108
|
+
"DaroAppKey",
|
|
109
|
+
"GADApplicationIdentifier",
|
|
110
|
+
"DaroAppLovinSdkKey",
|
|
111
|
+
"DaroAppLovinAdReviewKey",
|
|
112
|
+
]
|
|
113
|
+
var info: [String: Any] = [:]
|
|
114
|
+
for key in keys {
|
|
115
|
+
info[key] = Bundle.main.object(forInfoDictionaryKey: key) as? String ?? NSNull()
|
|
116
|
+
}
|
|
117
|
+
resolve(info)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@objc(getAdapterInventory:reject:)
|
|
121
|
+
func getAdapterInventory(
|
|
122
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
123
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
124
|
+
) {
|
|
125
|
+
// **여기서 GMA 를 깨우지 않는다.** 한때 `MobileAds.start` 로 스냅샷을 받았는데, 그러면
|
|
126
|
+
// 초기화 전에 부른 호출이 GMA 를 먼저 띄워 SDK 의 초기화 순서 검증을 망가뜨린다 —
|
|
127
|
+
// 그 가드를 화면 콜백 하나에만 두면 다른 호출자(진단 스크립트·소비자)가 그냥 밟는다.
|
|
128
|
+
// `initializationStatus` 는 읽기 전용이라 부작용이 없다.
|
|
129
|
+
//
|
|
130
|
+
// **iOS 는 손 목록을 두지 않는다.** Android 는 `adapterStatusMap` 이 초기화된 것만
|
|
131
|
+
// 담아 미탑재와 구분이 안 되므로 클래스명을 나열하지만, iOS 의
|
|
132
|
+
// `adapterStatusesByClassName` 은 **링크된 어댑터를 전부** 담는다 — 손 목록은
|
|
133
|
+
// 반드시 낡는다(iOS QA 앱 `SDKInitializer.adapterInventory` 의 실측 결정과 같다).
|
|
134
|
+
// 초기화 전에는 비어 있을 수 있는데, 그건 화면이 펼 때마다 다시 읽어 메운다.
|
|
135
|
+
DispatchQueue.main.async {
|
|
136
|
+
let status = MobileAds.shared.initializationStatus
|
|
137
|
+
let admob = status.adapterStatusesByClassName
|
|
138
|
+
.sorted { $0.key < $1.key }
|
|
139
|
+
.map { key, value in
|
|
140
|
+
[
|
|
141
|
+
"name": key.replacingOccurrences(of: "GADMediationAdapter", with: ""),
|
|
142
|
+
"detail": value.state == .ready ? "READY" : value.description,
|
|
143
|
+
"isReady": value.state == .ready,
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
let applovin = ALSdk.shared().availableMediatedNetworks
|
|
147
|
+
.sorted { $0.name < $1.name }
|
|
148
|
+
.map {
|
|
149
|
+
[
|
|
150
|
+
"name": $0.name,
|
|
151
|
+
"detail": $0.adapterVersion.isEmpty ? "미탑재" : $0.adapterVersion,
|
|
152
|
+
"isReady": !$0.adapterVersion.isEmpty,
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
resolve(["admob": admob, "applovin": applovin])
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React
|
|
2
2
|
|
|
3
|
-
extension
|
|
3
|
+
extension DaroRNModule {
|
|
4
4
|
@objc(isRewardedAdReady:adUnitId:resolve:reject:)
|
|
5
5
|
func isRewardedAdReady(
|
|
6
6
|
requestId: Double,
|
|
@@ -10,7 +10,7 @@ extension DaroMModule {
|
|
|
10
10
|
) {
|
|
11
11
|
let requestId = Int(requestId)
|
|
12
12
|
if !Self.sdkInitialized {
|
|
13
|
-
|
|
13
|
+
DaroRNModule.logger.debug("[DaroRNMobileAds] !isInitialized")
|
|
14
14
|
resolve(false)
|
|
15
15
|
return
|
|
16
16
|
}
|
|
@@ -63,25 +63,25 @@ extension DaroMModule {
|
|
|
63
63
|
} else {
|
|
64
64
|
let rewardedAdLoader = DaroRewardedAdLoader(unit: DaroAdUnit(unitId: adUnitId))
|
|
65
65
|
rewardedAdLoader.listener.onAdClicked = { [weak self] adInfo in
|
|
66
|
-
|
|
66
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad clicked")
|
|
67
67
|
self?.sendEvent(with: .onRewardedAdClickedEvent, body: adInfo?.toBody(requestId: requestId))
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
rewardedAdLoader.listener.onAdImpression = { [weak self] adInfo in
|
|
71
|
-
|
|
71
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad impression")
|
|
72
72
|
self?.rewardedAds[requestId]?.loadedAd = nil
|
|
73
73
|
self?.sendEvent(with: .onRewardedAdImpressionRecordedEvent, body: adInfo?.toBody(requestId: requestId))
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
rewardedAdLoader.listener.onAdLoadSuccess = { [weak self] ad, adInfo in
|
|
77
|
-
|
|
77
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad loaded")
|
|
78
78
|
self?.rewardedAds[requestId]?.loadedAd = ad
|
|
79
79
|
self?.sendEvent(with: .onRewardedAdLoadedEvent, body: adInfo?.toBody(requestId: requestId))
|
|
80
80
|
self?.setupRewardedListener(for: ad, requestId: requestId)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
rewardedAdLoader.listener.onAdLoadFail = { [weak self] error in
|
|
84
|
-
|
|
84
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad failed to load: \(error)")
|
|
85
85
|
self?.sendEvent(with: .onRewardedAdLoadFailedEvent, body: error.toBody(requestId: requestId))
|
|
86
86
|
}
|
|
87
87
|
self.rewardedAds[requestId] = RewardedAd(loader: rewardedAdLoader)
|
|
@@ -91,22 +91,22 @@ extension DaroMModule {
|
|
|
91
91
|
|
|
92
92
|
private func setupRewardedListener(for ad: DaroRewardedAd, requestId: Int) {
|
|
93
93
|
ad.rewardedAdListener.onShown = { [weak self] adInfo in
|
|
94
|
-
|
|
94
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad displayed")
|
|
95
95
|
self?.sendEvent(with: .onRewardedAdDisplayedEvent, body: adInfo?.toBody(requestId: requestId))
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
ad.rewardedAdListener.onDismiss = { [weak self] adInfo in
|
|
99
|
-
|
|
99
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad hidden")
|
|
100
100
|
self?.sendEvent(with: .onRewardedAdHiddenEvent, body: adInfo?.toBody(requestId: requestId))
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
ad.rewardedAdListener.onFailedToShow = { [weak self] adInfo, error in
|
|
104
|
-
|
|
104
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad failed to display: \(error)")
|
|
105
105
|
self?.sendEvent(with: .onRewardedAdFailedToDisplayEvent, body: adInfo?.toBody(requestId: requestId))
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
ad.rewardedAdListener.onEarnedReward = { [weak self] adInfo, rewardItem in
|
|
109
|
-
|
|
109
|
+
DaroRNModule.logger.debug("[DARO] Sample Rewarded Ad received reward")
|
|
110
110
|
self?.sendEvent(with: .onRewardedAdReceivedRewardEvent, body: rewardItem?.toBody(requestId: requestId, unitId: adInfo?.adUnitId ?? ""))
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#import <DaroReactNativeSpec/DaroReactNativeSpec.h>
|
|
6
6
|
#endif
|
|
7
7
|
|
|
8
|
-
@interface RCT_EXTERN_MODULE (
|
|
8
|
+
@interface RCT_EXTERN_MODULE (DaroRNModule, RCTEventEmitter)
|
|
9
9
|
|
|
10
10
|
#pragma mark - Initialization
|
|
11
11
|
|
|
@@ -13,9 +13,24 @@ RCT_EXTERN_METHOD(isInitialized:(RCTPromiseResolveBlock)resolve reject:(RCTPromi
|
|
|
13
13
|
RCT_EXTERN_METHOD(initializeSdk:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
14
14
|
RCT_EXTERN_METHOD(setUserId:(NSString *)userId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
15
15
|
|
|
16
|
+
#pragma mark - Consent
|
|
17
|
+
|
|
18
|
+
RCT_EXTERN_METHOD(setGdpr:(NSString *)status consentString:(NSString *)consentString resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
19
|
+
RCT_EXTERN_METHOD(setCcpa:(NSString *)status consentString:(NSString *)consentString resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
20
|
+
RCT_EXTERN_METHOD(setCoppa:(NSString *)status resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
21
|
+
|
|
16
22
|
#pragma mark - Mediation Debugger
|
|
17
23
|
|
|
18
24
|
RCT_EXTERN_METHOD(showMediationDebugger:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
25
|
+
RCT_EXTERN_METHOD(showMediationDebuggerFor:(NSString *)mediation resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
26
|
+
|
|
27
|
+
#pragma mark - QA Surface
|
|
28
|
+
|
|
29
|
+
RCT_EXTERN_METHOD(getSdkVersion:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
30
|
+
RCT_EXTERN_METHOD(getMediationStatuses:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
31
|
+
RCT_EXTERN_METHOD(getMediationWeights:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
32
|
+
RCT_EXTERN_METHOD(getAdapterInventory:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
33
|
+
RCT_EXTERN_METHOD(getIntegrationKeyInfo:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
19
34
|
|
|
20
35
|
#pragma mark - Interstitial
|
|
21
36
|
|
|
@@ -33,7 +48,7 @@ RCT_EXTERN_METHOD(showRewardedAd:(double)requestId adUnitId:(NSString *)adUnitId
|
|
|
33
48
|
|
|
34
49
|
RCT_EXTERN_METHOD(isAppOpenAdReady:(double)requestId adUnitId:(NSString *)adUnitId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
35
50
|
RCT_EXTERN_METHOD(loadAppOpenAd:(double)requestId adUnitId:(NSString *)adUnitId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
36
|
-
RCT_EXTERN_METHOD(showAppOpenAd:(double)requestId adUnitId:(NSString *)adUnitId
|
|
51
|
+
RCT_EXTERN_METHOD(showAppOpenAd:(double)requestId adUnitId:(NSString *)adUnitId customData:(nullable NSString *)customData resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
37
52
|
|
|
38
53
|
#pragma mark - Light Popup
|
|
39
54
|
|
|
@@ -50,10 +65,10 @@ RCT_EXTERN_METHOD(setLightPopupAdConfiguration:(double)requestId adUnitId:(NSStr
|
|
|
50
65
|
|
|
51
66
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
52
67
|
|
|
53
|
-
@interface
|
|
68
|
+
@interface DaroRNModule (TurboModule) <RCTTurboModule>
|
|
54
69
|
@end
|
|
55
70
|
|
|
56
|
-
@implementation
|
|
71
|
+
@implementation DaroRNModule (TurboModule)
|
|
57
72
|
|
|
58
73
|
- (facebook::react::ModuleConstants<JS::NativeDaroModule::Constants>)getConstants
|
|
59
74
|
{
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React
|
|
2
2
|
import os.log
|
|
3
3
|
|
|
4
|
-
@objc(
|
|
5
|
-
class
|
|
4
|
+
@objc(DaroRNModule)
|
|
5
|
+
class DaroRNModule: RCTEventEmitter {
|
|
6
6
|
|
|
7
7
|
// 중앙집중식 로거 - 다른 파일에서도 사용 가능
|
|
8
|
-
static let logger = Logger(subsystem: "com.
|
|
8
|
+
static let logger = Logger(subsystem: "com.daro.reactnative", category: "DaroRNModule")
|
|
9
9
|
|
|
10
10
|
enum Event: String, CaseIterable {
|
|
11
11
|
|
|
@@ -172,7 +172,7 @@ class DaroMModule: RCTEventEmitter {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// MARK: - Constants
|
|
175
|
-
extension
|
|
175
|
+
extension DaroRNModule {
|
|
176
176
|
|
|
177
177
|
// https://reactnative.dev/docs/legacy/native-modules-ios#sending-events-to-javascript
|
|
178
178
|
// Sending Events to JavaScript
|
|
@@ -188,18 +188,32 @@ extension DaroMModule {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
// MARK: - Helpers
|
|
191
|
-
extension
|
|
191
|
+
extension DaroRNModule {
|
|
192
192
|
func sendEvent(with event: Event, body: Any?) {
|
|
193
193
|
sendEvent(withName: event.rawValue, body: body)
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
extension DaroAdInfo {
|
|
198
|
+
// 모듈 경로와 뷰 경로(DaroRNBannerAdView·DaroRNNativeAdView)가 **둘 다 여기를 지난다.**
|
|
198
199
|
var toBody: [String: Any] {
|
|
199
|
-
|
|
200
|
+
var body: [String: Any] = [
|
|
200
201
|
"adUnitId": self.adUnitId,
|
|
201
202
|
"latencyMillis": self.latency as Any,
|
|
202
203
|
]
|
|
204
|
+
// 없을 때는 키를 넣지 않는다 — [String: Any] 에 nil 을 담으면 JS 에서 null 로
|
|
205
|
+
// 보이고, 타입은 옵셔널이라 undefined 여야 한다.
|
|
206
|
+
//
|
|
207
|
+
// SDK 가 정한 어휘를 **그대로** 넘긴다. 래퍼에서 매핑하지 않는다 — 발행 tarball 이
|
|
208
|
+
// android/ios 를 소스로 싣기 때문에 여기 매핑을 두면 그대로 읽힌다.
|
|
209
|
+
if let mediationPlatform = self.mediationPlatform {
|
|
210
|
+
body["mediationPlatform"] = mediationPlatform
|
|
211
|
+
}
|
|
212
|
+
// 벤더 어휘. 정규화하지 않는다 (AdMob responseInfo.adNetwork / AppLovin networkName).
|
|
213
|
+
if let adNetwork = self.adNetwork {
|
|
214
|
+
body["adNetwork"] = adNetwork
|
|
215
|
+
}
|
|
216
|
+
return body
|
|
203
217
|
}
|
|
204
218
|
|
|
205
219
|
func toBody(requestId: Int) -> [String: Any] {
|
|
@@ -0,0 +1,219 @@
|
|
|
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 NSString *DaroRNFabricNSStringFromStdString(const std::string &value);
|
|
22
|
+
extern NSDictionary *DaroRNFabricEventBody(NSDictionary *body);
|
|
23
|
+
extern std::string DaroRNFabricEventString(NSDictionary *body, NSString *key);
|
|
24
|
+
extern double DaroRNFabricEventDouble(NSDictionary *body, NSString *key);
|
|
25
|
+
extern int DaroRNFabricEventInt(NSDictionary *body, NSString *key);
|
|
26
|
+
|
|
27
|
+
@interface DaroRNAdBannerViewComponentView : RCTViewComponentView <RCTDaroRNAdBannerViewViewProtocol>
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation DaroRNAdBannerViewComponentView {
|
|
31
|
+
UIView *_bannerView;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
+ (void)load
|
|
35
|
+
{
|
|
36
|
+
[super load];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
40
|
+
{
|
|
41
|
+
if (self = [super initWithFrame:frame]) {
|
|
42
|
+
static const auto defaultProps = std::make_shared<const DaroRNAdBannerViewProps>();
|
|
43
|
+
_props = defaultProps;
|
|
44
|
+
[self createBannerView];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return self;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)createBannerView
|
|
51
|
+
{
|
|
52
|
+
_bannerView = DaroRNFabricCreateSwiftView(@"DaroRNAdBannerView");
|
|
53
|
+
self.contentView = _bannerView;
|
|
54
|
+
[self installEventHandlers];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)installEventHandlers
|
|
58
|
+
{
|
|
59
|
+
__weak DaroRNAdBannerViewComponentView *weakSelf = self;
|
|
60
|
+
|
|
61
|
+
RCTDirectEventBlock onAdLoadedEvent = ^(NSDictionary *body) {
|
|
62
|
+
DaroRNAdBannerViewComponentView *strongSelf = weakSelf;
|
|
63
|
+
if (!strongSelf) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
|
|
68
|
+
if (!eventEmitter) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
73
|
+
eventEmitter->onAdLoadedEvent({
|
|
74
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
75
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
76
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
77
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
78
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
79
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
RCTDirectEventBlock onAdLoadFailedEvent = ^(NSDictionary *body) {
|
|
84
|
+
DaroRNAdBannerViewComponentView *strongSelf = weakSelf;
|
|
85
|
+
if (!strongSelf) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
|
|
90
|
+
if (!eventEmitter) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
95
|
+
eventEmitter->onAdLoadFailedEvent({
|
|
96
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
97
|
+
.code = DaroRNFabricEventInt(eventBody, @"code"),
|
|
98
|
+
.message = DaroRNFabricEventString(eventBody, @"message"),
|
|
99
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
RCTDirectEventBlock onAdClickedEvent = ^(NSDictionary *body) {
|
|
104
|
+
DaroRNAdBannerViewComponentView *strongSelf = weakSelf;
|
|
105
|
+
if (!strongSelf) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
|
|
110
|
+
if (!eventEmitter) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
115
|
+
eventEmitter->onAdClickedEvent({
|
|
116
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
117
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
118
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
119
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
120
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
121
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
RCTDirectEventBlock onAdImpressionRecordedEvent = ^(NSDictionary *body) {
|
|
126
|
+
DaroRNAdBannerViewComponentView *strongSelf = weakSelf;
|
|
127
|
+
if (!strongSelf) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
auto eventEmitter = std::static_pointer_cast<const DaroRNAdBannerViewEventEmitter>(strongSelf->_eventEmitter);
|
|
132
|
+
if (!eventEmitter) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
NSDictionary *eventBody = DaroRNFabricEventBody(body);
|
|
137
|
+
eventEmitter->onAdImpressionRecordedEvent({
|
|
138
|
+
.adUnitId = DaroRNFabricEventString(eventBody, @"adUnitId"),
|
|
139
|
+
.latencyMillis = DaroRNFabricEventDouble(eventBody, @"latencyMillis"),
|
|
140
|
+
// Fabric 이벤트는 타입 있는 구조체다 — **여기 안 적으면 네이티브가 보내도 JS 에 안 온다.**
|
|
141
|
+
// Android 는 맵을 통째로 넘겨서 안 걸린다. codegen 타입만 넓히면 부족하다.
|
|
142
|
+
.mediationPlatform = DaroRNFabricEventString(eventBody, @"mediationPlatform"),
|
|
143
|
+
.adNetwork = DaroRNFabricEventString(eventBody, @"adNetwork"),
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
DaroRNFabricSetValue(_bannerView, @"onAdLoadedEvent", onAdLoadedEvent);
|
|
148
|
+
DaroRNFabricSetValue(_bannerView, @"onAdLoadFailedEvent", onAdLoadFailedEvent);
|
|
149
|
+
DaroRNFabricSetValue(_bannerView, @"onAdClickedEvent", onAdClickedEvent);
|
|
150
|
+
DaroRNFabricSetValue(_bannerView, @"onAdImpressionRecordedEvent", onAdImpressionRecordedEvent);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
154
|
+
{
|
|
155
|
+
return concreteComponentDescriptorProvider<DaroRNAdBannerViewComponentDescriptor>();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
159
|
+
{
|
|
160
|
+
const auto &oldComponentProps = *std::static_pointer_cast<const DaroRNAdBannerViewProps>(_props);
|
|
161
|
+
const auto &newComponentProps = *std::static_pointer_cast<const DaroRNAdBannerViewProps>(props);
|
|
162
|
+
NSMutableArray<NSString *> *changedProps = [NSMutableArray new];
|
|
163
|
+
|
|
164
|
+
if (oldComponentProps.adUnitId != newComponentProps.adUnitId) {
|
|
165
|
+
DaroRNFabricSetValue(_bannerView, @"adUnitId", DaroRNFabricNSStringFromStdString(newComponentProps.adUnitId));
|
|
166
|
+
[changedProps addObject:@"adUnitId"];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (oldComponentProps.adFormat != newComponentProps.adFormat) {
|
|
170
|
+
DaroRNFabricSetValue(_bannerView, @"adFormat", DaroRNFabricNSStringFromStdString(newComponentProps.adFormat));
|
|
171
|
+
[changedProps addObject:@"adFormat"];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (oldComponentProps.loadOnMount != newComponentProps.loadOnMount) {
|
|
175
|
+
DaroRNFabricSetValue(_bannerView, @"loadOnMount", @(newComponentProps.loadOnMount));
|
|
176
|
+
[changedProps addObject:@"loadOnMount"];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (oldComponentProps.isVisible != newComponentProps.isVisible) {
|
|
180
|
+
DaroRNFabricSetValue(_bannerView, @"isVisible", @(newComponentProps.isVisible));
|
|
181
|
+
[changedProps addObject:@"isVisible"];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
[super updateProps:props oldProps:oldProps];
|
|
185
|
+
|
|
186
|
+
DaroRNFabricPerformSelectorWithObject(_bannerView, NSSelectorFromString(@"applyReactProps:"), changedProps);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
- (void)loadAd
|
|
190
|
+
{
|
|
191
|
+
DaroRNFabricPerformSelector(_bannerView, NSSelectorFromString(@"loadAd"));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
|
|
195
|
+
{
|
|
196
|
+
RCTDaroRNAdBannerViewHandleCommand(self, commandName, args);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
- (void)prepareForRecycle
|
|
200
|
+
{
|
|
201
|
+
[super prepareForRecycle];
|
|
202
|
+
DaroRNFabricSetValue(_bannerView, @"onAdLoadedEvent", nil);
|
|
203
|
+
DaroRNFabricSetValue(_bannerView, @"onAdLoadFailedEvent", nil);
|
|
204
|
+
DaroRNFabricSetValue(_bannerView, @"onAdClickedEvent", nil);
|
|
205
|
+
DaroRNFabricSetValue(_bannerView, @"onAdImpressionRecordedEvent", nil);
|
|
206
|
+
DaroRNFabricPerformSelector(_bannerView, NSSelectorFromString(@"prepareForReuse"));
|
|
207
|
+
[self installEventHandlers];
|
|
208
|
+
static const auto defaultProps = std::make_shared<const DaroRNAdBannerViewProps>();
|
|
209
|
+
_props = defaultProps;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@end
|
|
213
|
+
|
|
214
|
+
Class<RCTComponentViewProtocol> DaroRNAdBannerViewCls(void)
|
|
215
|
+
{
|
|
216
|
+
return DaroRNAdBannerViewComponentView.class;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
#endif
|
|
@@ -5,24 +5,24 @@
|
|
|
5
5
|
#import <Foundation/Foundation.h>
|
|
6
6
|
#include <string>
|
|
7
7
|
|
|
8
|
-
NSDictionary *
|
|
8
|
+
NSDictionary *DaroRNFabricEventBody(NSDictionary *body)
|
|
9
9
|
{
|
|
10
10
|
return [body isKindOfClass:NSDictionary.class] ? body : @{};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
std::string
|
|
13
|
+
std::string DaroRNFabricEventString(NSDictionary *body, NSString *key)
|
|
14
14
|
{
|
|
15
15
|
id value = body[key];
|
|
16
16
|
return [value isKindOfClass:NSString.class] ? std::string([value UTF8String]) : "";
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
double
|
|
19
|
+
double DaroRNFabricEventDouble(NSDictionary *body, NSString *key)
|
|
20
20
|
{
|
|
21
21
|
id value = body[key];
|
|
22
22
|
return [value respondsToSelector:@selector(doubleValue)] ? [value doubleValue] : 0;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
int
|
|
25
|
+
int DaroRNFabricEventInt(NSDictionary *body, NSString *key)
|
|
26
26
|
{
|
|
27
27
|
id value = body[key];
|
|
28
28
|
return [value respondsToSelector:@selector(intValue)] ? [value intValue] : 0;
|