react-native-daro 1.0.12 → 1.0.15
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/LICENSE +1 -1
- package/README.md +30 -30
- package/android/build.gradle +42 -59
- package/android/src/admob/java/com/daro/reactnative/DaroSdkBridge.kt +23 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/{darom → daro/reactnative}/DaroMAdBannerViewManager.kt +4 -4
- package/android/src/main/java/com/{darom → daro/reactnative}/DaroMAdNativeViewManager.kt +4 -4
- package/android/src/main/java/com/{darom → daro/reactnative}/DaroMModule.kt +44 -45
- package/android/src/main/java/com/{darom → daro/reactnative}/DaroMPackage.kt +1 -1
- package/android/src/main/java/com/{darom → daro/reactnative}/constants/InternalDaroMBannerSize.kt +1 -1
- package/android/src/main/java/com/{darom → daro/reactnative}/event/DaroMEvent.kt +1 -1
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMBannerViewModuleImpl.kt +2 -2
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMInterstitialModuleImpl.kt +26 -26
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMLightPopupModuleImpl.kt +30 -29
- package/android/src/main/java/com/{darom → daro/reactnative}/impl/DaroMRewardedAdModuleImpl.kt +33 -27
- package/android/src/main/java/com/{darom → daro/reactnative}/util/AdInfoUtil.kt +25 -1
- package/android/src/main/java/com/{darom → daro/reactnative}/util/EventEmitterUtil.kt +2 -2
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdBannerViewContainer.kt +417 -0
- package/android/src/main/java/com/{darom → daro/reactnative}/view/DaroMAdNativeViewContainer.kt +4 -4
- package/app.plugin.js +1 -0
- package/ios/DaroMAdBannerViewManager.swift +5 -1
- package/ios/DaroMModule+AppOpen.swift +34 -31
- package/ios/DaroMModule+Interstitial.swift +29 -26
- package/ios/DaroMModule+LightPopup.swift +40 -33
- package/ios/DaroMModule+Rewarded.swift +35 -27
- package/ios/DaroMModule.mm +13 -13
- package/ios/DaroMModule.swift +20 -13
- package/ios/DaroMNativeAdViewManager.swift +1 -1
- package/ios/mediation/admob/DaroMediationDebugger.swift +11 -0
- package/ios/mediation/admob/DaroMediationTypes.swift +22 -0
- package/lib/commonjs/AdBannerView.js +6 -1
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +155 -70
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/ErrorCode.js.map +1 -1
- package/lib/commonjs/EventEmitter.js +39 -11
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/InterstitialAd.js +157 -70
- package/lib/commonjs/InterstitialAd.js.map +1 -1
- package/lib/commonjs/LightPopupAd.js +181 -99
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/RewardedAd.js +164 -80
- package/lib/commonjs/RewardedAd.js.map +1 -1
- package/lib/commonjs/index.js +1 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +5 -1
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types/AdEvent.js +17 -0
- package/lib/commonjs/types/AdEvent.js.map +1 -1
- package/lib/module/AdBannerView.js +6 -1
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +155 -71
- package/lib/module/AppOpenAd.js.map +1 -1
- package/lib/module/ErrorCode.js.map +1 -1
- package/lib/module/EventEmitter.js +37 -10
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/InterstitialAd.js +158 -72
- package/lib/module/InterstitialAd.js.map +1 -1
- package/lib/module/LightPopupAd.js +182 -100
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/RewardedAd.js +165 -82
- package/lib/module/RewardedAd.js.map +1 -1
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +5 -1
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types/AdEvent.js +18 -1
- package/lib/module/types/AdEvent.js.map +1 -1
- package/lib/typescript/commonjs/plugin/src/index.d.ts +19 -0
- package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts +6 -0
- package/lib/typescript/commonjs/plugin/src/skAdNetworkIds.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts +8 -0
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -0
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts +8 -0
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/AdBannerView.d.ts +124 -2
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts +53 -2
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ErrorCode.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/EventEmitter.d.ts +9 -1
- package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts +53 -2
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts +57 -2
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/RewardedAd.d.ts +57 -2
- package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +124 -2
- 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.map +1 -1
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdEvent.d.ts +24 -0
- package/lib/typescript/commonjs/src/types/AdEvent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/AdProps.d.ts +2 -2
- package/lib/typescript/commonjs/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/DaroMMobileAds.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/LightPopupAd.d.ts +1 -5
- package/lib/typescript/commonjs/src/types/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/index.d.ts +19 -0
- package/lib/typescript/module/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts +6 -0
- package/lib/typescript/module/plugin/src/skAdNetworkIds.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/withAndroid.d.ts +8 -0
- package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -0
- package/lib/typescript/module/plugin/src/withIos.d.ts +8 -0
- package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -0
- package/lib/typescript/module/src/AdBannerView.d.ts +124 -2
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/module/src/AppOpenAd.d.ts +53 -2
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/module/src/ErrorCode.d.ts.map +1 -1
- package/lib/typescript/module/src/EventEmitter.d.ts +9 -1
- package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/module/src/InterstitialAd.d.ts +53 -2
- package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/module/src/LightPopupAd.d.ts +57 -2
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/RewardedAd.d.ts +57 -2
- package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +124 -2
- 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.map +1 -1
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts +2 -2
- package/lib/typescript/module/src/types/AdBannerViewProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdEvent.d.ts +24 -0
- package/lib/typescript/module/src/types/AdEvent.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdInfo.d.ts.map +1 -1
- package/lib/typescript/module/src/types/AdProps.d.ts +2 -2
- package/lib/typescript/module/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/module/src/types/DaroMMobileAds.d.ts.map +1 -1
- package/lib/typescript/module/src/types/LightPopupAd.d.ts +1 -5
- package/lib/typescript/module/src/types/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +88 -101
- package/plugin/build/index.d.ts +18 -0
- package/plugin/build/index.js +71 -0
- package/plugin/build/skAdNetworkIds.d.ts +5 -0
- package/plugin/build/skAdNetworkIds.js +205 -0
- package/plugin/build/withAndroid.d.ts +7 -0
- package/plugin/build/withAndroid.js +140 -0
- package/plugin/build/withIos.d.ts +7 -0
- package/plugin/build/withIos.js +83 -0
- package/react-native-daro.podspec +25 -0
- package/src/AdBannerView.tsx +54 -17
- package/src/AppOpenAd.ts +216 -104
- package/src/ErrorCode.ts +1 -2
- package/src/EventEmitter.ts +63 -14
- package/src/InterstitialAd.ts +216 -104
- package/src/LightPopupAd.ts +240 -114
- package/src/RewardedAd.ts +233 -122
- package/src/index.tsx +20 -12
- package/src/nativeAd/NativeAdView.tsx +65 -14
- package/src/nativeAd/NativeAdViewComponents.tsx +54 -27
- package/src/nativeAd/NativeAdViewProvider.tsx +17 -7
- package/src/types/AdBannerViewProps.ts +11 -11
- package/src/types/AdEvent.ts +39 -2
- package/src/types/AdInfo.ts +17 -17
- package/src/types/AdProps.ts +8 -9
- package/src/types/DaroMMobileAds.ts +3 -6
- package/src/types/LightPopupAd.ts +2 -7
- package/src/types/NativeAdViewProps.ts +5 -5
- package/src/types/index.ts +1 -1
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifestNew.xml +0 -7
- package/android/src/main/java/com/darom/view/DaroMAdBannerViewContainer.kt +0 -163
- package/android/src/main/res/layout/layout_activity_transparent.xml +0 -7
- package/android/src/main/res/values/styles.xml +0 -11
- package/ios/DaroM-Bridging-Header.h +0 -6
- package/lib/commonjs/types/AppOpenAd.js +0 -6
- package/lib/commonjs/types/AppOpenAd.js.map +0 -1
- package/lib/commonjs/types/FullScreenAd.js +0 -6
- package/lib/commonjs/types/FullScreenAd.js.map +0 -1
- package/lib/commonjs/types/InterstitialAd.js +0 -6
- package/lib/commonjs/types/InterstitialAd.js.map +0 -1
- package/lib/commonjs/types/RewardedAd.js +0 -6
- package/lib/commonjs/types/RewardedAd.js.map +0 -1
- package/lib/module/types/AppOpenAd.js +0 -4
- package/lib/module/types/AppOpenAd.js.map +0 -1
- package/lib/module/types/FullScreenAd.js +0 -4
- package/lib/module/types/FullScreenAd.js.map +0 -1
- package/lib/module/types/InterstitialAd.js +0 -4
- package/lib/module/types/InterstitialAd.js.map +0 -1
- package/lib/module/types/RewardedAd.js +0 -4
- package/lib/module/types/RewardedAd.js.map +0 -1
- package/lib/typescript/commonjs/src/types/AppOpenAd.d.ts +0 -3
- package/lib/typescript/commonjs/src/types/AppOpenAd.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/FullScreenAd.d.ts +0 -21
- package/lib/typescript/commonjs/src/types/FullScreenAd.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/InterstitialAd.d.ts +0 -3
- package/lib/typescript/commonjs/src/types/InterstitialAd.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/types/RewardedAd.d.ts +0 -9
- package/lib/typescript/commonjs/src/types/RewardedAd.d.ts.map +0 -1
- package/lib/typescript/module/src/types/AppOpenAd.d.ts +0 -3
- package/lib/typescript/module/src/types/AppOpenAd.d.ts.map +0 -1
- package/lib/typescript/module/src/types/FullScreenAd.d.ts +0 -21
- package/lib/typescript/module/src/types/FullScreenAd.d.ts.map +0 -1
- package/lib/typescript/module/src/types/InterstitialAd.d.ts +0 -3
- package/lib/typescript/module/src/types/InterstitialAd.d.ts.map +0 -1
- package/lib/typescript/module/src/types/RewardedAd.d.ts +0 -9
- package/lib/typescript/module/src/types/RewardedAd.d.ts.map +0 -1
- package/react-native-daro-m.podspec +0 -44
- package/src/types/AppOpenAd.ts +0 -3
- package/src/types/FullScreenAd.ts +0 -28
- package/src/types/InterstitialAd.ts +0 -3
- package/src/types/RewardedAd.ts +0 -15
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.withAndroidConfiguration = void 0;
|
|
37
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const KEY_FILE_NAME = 'android-daro-key.txt';
|
|
41
|
+
const DARO_GRADLE_PLUGIN_CLASSPATH = 'so.daro:daro-plugin:1.0.13';
|
|
42
|
+
const MAX_QUALITY_CLASSPATH = 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:5.5.2';
|
|
43
|
+
const MAX_MAVEN_REPO = 'https://artifacts.applovin.com/android';
|
|
44
|
+
const DARO_APP_PLUGIN_IDS = {
|
|
45
|
+
admob: 'so.daro.a',
|
|
46
|
+
max: 'so.daro.m',
|
|
47
|
+
};
|
|
48
|
+
const DARO_MAVEN_REPOS = [
|
|
49
|
+
'https://artifact.bytedance.com/repository/pangle',
|
|
50
|
+
'https://cboost.jfrog.io/artifactory/chartboost-ads/',
|
|
51
|
+
'https://android-sdk.is.com/',
|
|
52
|
+
'https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea',
|
|
53
|
+
];
|
|
54
|
+
function replaceOrThrow(contents, pattern, replacement, target) {
|
|
55
|
+
if (!pattern.test(contents)) {
|
|
56
|
+
throw new Error(`[daro-react-native] Cannot automatically update android/build.gradle. ` +
|
|
57
|
+
`Expected to find ${target}.`);
|
|
58
|
+
}
|
|
59
|
+
return contents.replace(pattern, replacement);
|
|
60
|
+
}
|
|
61
|
+
const withAndroidConfiguration = (config, props) => {
|
|
62
|
+
const { mediation } = props;
|
|
63
|
+
const daroAppPluginId = DARO_APP_PLUGIN_IDS[mediation];
|
|
64
|
+
// 1. project build.gradle: classpath + maven repos
|
|
65
|
+
config = (0, config_plugins_1.withProjectBuildGradle)(config, (gradleConfig) => {
|
|
66
|
+
if (gradleConfig.modResults.language !== 'groovy') {
|
|
67
|
+
config_plugins_1.WarningAggregator.addWarningAndroid('daro-react-native', 'Cannot automatically configure project build.gradle if it is not groovy.');
|
|
68
|
+
return gradleConfig;
|
|
69
|
+
}
|
|
70
|
+
let contents = gradleConfig.modResults.contents;
|
|
71
|
+
if (!contents.includes(DARO_GRADLE_PLUGIN_CLASSPATH)) {
|
|
72
|
+
contents = replaceOrThrow(contents, /dependencies\s*\{/, (match) => `${match}\n classpath("${DARO_GRADLE_PLUGIN_CLASSPATH}")`, 'a buildscript dependencies block');
|
|
73
|
+
}
|
|
74
|
+
if (mediation === 'max' && !contents.includes(MAX_QUALITY_CLASSPATH)) {
|
|
75
|
+
contents = replaceOrThrow(contents, /dependencies\s*\{/, (match) => `${match}\n classpath("${MAX_QUALITY_CLASSPATH}")`, 'a buildscript dependencies block');
|
|
76
|
+
}
|
|
77
|
+
const mavenRepos = mediation === 'max'
|
|
78
|
+
? [MAX_MAVEN_REPO, ...DARO_MAVEN_REPOS]
|
|
79
|
+
: DARO_MAVEN_REPOS;
|
|
80
|
+
for (const url of mavenRepos) {
|
|
81
|
+
if (contents.includes(url))
|
|
82
|
+
continue;
|
|
83
|
+
contents = replaceOrThrow(contents, /allprojects\s*\{[\s\S]*?repositories\s*\{/, (match) => `${match}\n maven { url = uri("${url}") }`, 'an allprojects repositories block');
|
|
84
|
+
}
|
|
85
|
+
if (mediation === 'max' &&
|
|
86
|
+
!contents.includes('daro-react-native-max-buildscript-repo')) {
|
|
87
|
+
contents = replaceOrThrow(contents, /buildscript\s*\{[\s\S]*?repositories\s*\{/, (match) => `${match}\n // daro-react-native-max-buildscript-repo\n maven { url = uri("${MAX_MAVEN_REPO}") }`, 'a buildscript repositories block');
|
|
88
|
+
}
|
|
89
|
+
gradleConfig.modResults.contents = contents;
|
|
90
|
+
return gradleConfig;
|
|
91
|
+
});
|
|
92
|
+
// 2. app/build.gradle: apply selected Daro mediation plugin.
|
|
93
|
+
config = (0, config_plugins_1.withAppBuildGradle)(config, (gradleConfig) => {
|
|
94
|
+
if (gradleConfig.modResults.language !== 'groovy') {
|
|
95
|
+
config_plugins_1.WarningAggregator.addWarningAndroid('daro-react-native', 'Cannot automatically configure app/build.gradle if it is not groovy.');
|
|
96
|
+
return gradleConfig;
|
|
97
|
+
}
|
|
98
|
+
let contents = gradleConfig.modResults.contents.replace(/\n?apply plugin: ['"]so\.daro\.[am]['"]\n?/g, '\n');
|
|
99
|
+
if (contents.includes(daroAppPluginId))
|
|
100
|
+
return gradleConfig;
|
|
101
|
+
gradleConfig.modResults.contents = `${contents.trimEnd()}\napply plugin: "${daroAppPluginId}"\n`;
|
|
102
|
+
return gradleConfig;
|
|
103
|
+
});
|
|
104
|
+
// 3. gradle.properties: daroAppKey + Jetifier
|
|
105
|
+
config = (0, config_plugins_1.withGradleProperties)(config, (propertiesConfig) => {
|
|
106
|
+
const entries = [
|
|
107
|
+
{ key: 'daroMediation', value: mediation },
|
|
108
|
+
{ key: 'daroAppKey', value: props.daroAppKey },
|
|
109
|
+
{ key: 'android.useAndroidX', value: 'true' },
|
|
110
|
+
{ key: 'android.enableJetifier', value: 'true' },
|
|
111
|
+
];
|
|
112
|
+
for (const { key, value } of entries) {
|
|
113
|
+
const existingIndex = propertiesConfig.modResults.findIndex((item) => item.type === 'property' && item.key === key);
|
|
114
|
+
const entry = { type: 'property', key, value };
|
|
115
|
+
if (existingIndex >= 0) {
|
|
116
|
+
propertiesConfig.modResults[existingIndex] = entry;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
propertiesConfig.modResults.push(entry);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return propertiesConfig;
|
|
123
|
+
});
|
|
124
|
+
// 4. daroKeyFile을 android/app/ 루트에 복사
|
|
125
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
126
|
+
'android',
|
|
127
|
+
async (dangerousConfig) => {
|
|
128
|
+
const sourcePath = path.resolve(dangerousConfig.modRequest.projectRoot, props.daroKeyFile);
|
|
129
|
+
if (!fs.existsSync(sourcePath)) {
|
|
130
|
+
throw new Error(`[daro-react-native] Cannot find Android key file at "${sourcePath}". ` +
|
|
131
|
+
`Set "android.daroKeyFile" in plugin options to a valid path.`);
|
|
132
|
+
}
|
|
133
|
+
const destinationPath = path.resolve(dangerousConfig.modRequest.platformProjectRoot, 'app', KEY_FILE_NAME);
|
|
134
|
+
fs.mkdirSync(path.dirname(destinationPath), { recursive: true });
|
|
135
|
+
fs.copyFileSync(sourcePath, destinationPath);
|
|
136
|
+
return dangerousConfig;
|
|
137
|
+
},
|
|
138
|
+
]);
|
|
139
|
+
};
|
|
140
|
+
exports.withAndroidConfiguration = withAndroidConfiguration;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConfigPlugin } from 'expo/config-plugins';
|
|
2
|
+
import type { DaroIosProps, DaroMediation } from './index';
|
|
3
|
+
type DaroResolvedIosProps = DaroIosProps & {
|
|
4
|
+
mediation: DaroMediation;
|
|
5
|
+
};
|
|
6
|
+
export declare const withIosConfiguration: ConfigPlugin<DaroResolvedIosProps>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.withIosConfiguration = void 0;
|
|
37
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const skAdNetworkIds_1 = require("./skAdNetworkIds");
|
|
41
|
+
const KEY_FILE_NAME = 'ios-daro-key.txt';
|
|
42
|
+
const DEFAULT_ATT_USAGE_DESCRIPTION = 'This identifier will be used to deliver personalized ads to you.';
|
|
43
|
+
const withIosConfiguration = (config, props) => {
|
|
44
|
+
const { mediation } = props;
|
|
45
|
+
config = (0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
46
|
+
config.modResults.DaroAppKey = props.daroAppKey;
|
|
47
|
+
config.modResults.NSUserTrackingUsageDescription =
|
|
48
|
+
props.attUsageDescription ?? DEFAULT_ATT_USAGE_DESCRIPTION;
|
|
49
|
+
if (mediation === 'admob') {
|
|
50
|
+
if (!props.admobAppId) {
|
|
51
|
+
throw new Error('[daro-react-native] "ios.admobAppId" is required when mediation is "admob".');
|
|
52
|
+
}
|
|
53
|
+
config.modResults.GADApplicationIdentifier = props.admobAppId;
|
|
54
|
+
}
|
|
55
|
+
// SKAdNetworkItems: 사용자가 미리 추가한 항목과 머지 (중복 제거)
|
|
56
|
+
const existing = config.modResults.SKAdNetworkItems ??
|
|
57
|
+
[];
|
|
58
|
+
const existingIds = new Set(existing.map((item) => item.SKAdNetworkIdentifier));
|
|
59
|
+
const additions = skAdNetworkIds_1.DARO_SK_AD_NETWORK_IDS.filter((id) => !existingIds.has(id)).map((id) => ({ SKAdNetworkIdentifier: id }));
|
|
60
|
+
config.modResults.SKAdNetworkItems = [...existing, ...additions];
|
|
61
|
+
return config;
|
|
62
|
+
});
|
|
63
|
+
return (0, config_plugins_1.withXcodeProject)(config, (config) => {
|
|
64
|
+
const projectRoot = config.modRequest.projectRoot;
|
|
65
|
+
const projectName = config.modRequest.projectName ??
|
|
66
|
+
config_plugins_1.IOSConfig.XcodeUtils.getProjectName(projectRoot);
|
|
67
|
+
const sourcePath = path.resolve(projectRoot, props.daroKeyFile);
|
|
68
|
+
if (!fs.existsSync(sourcePath)) {
|
|
69
|
+
throw new Error(`[daro-react-native] Cannot find iOS key file at "${sourcePath}". ` +
|
|
70
|
+
`Set "ios.daroKeyFile" in plugin options to a valid path.`);
|
|
71
|
+
}
|
|
72
|
+
const destinationPath = path.resolve(config_plugins_1.IOSConfig.Paths.getSourceRoot(projectRoot), KEY_FILE_NAME);
|
|
73
|
+
fs.copyFileSync(sourcePath, destinationPath);
|
|
74
|
+
config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
75
|
+
filepath: `${projectName}/${KEY_FILE_NAME}`,
|
|
76
|
+
groupName: projectName,
|
|
77
|
+
project: config.modResults,
|
|
78
|
+
isBuildFile: true,
|
|
79
|
+
});
|
|
80
|
+
return config;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
exports.withIosConfiguration = withIosConfiguration;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "react-native-daro"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/delightroom/daro-react-native.git", :tag => "react-native-daro@#{package["version"]}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = [
|
|
17
|
+
"ios/*.{h,m,mm,swift,cpp}",
|
|
18
|
+
"ios/mediation/admob/**/*.{h,m,mm,swift,cpp}"
|
|
19
|
+
]
|
|
20
|
+
s.private_header_files = "ios/**/*.h"
|
|
21
|
+
|
|
22
|
+
s.dependency "DaroAds", "1.1.59"
|
|
23
|
+
|
|
24
|
+
install_modules_dependencies(s)
|
|
25
|
+
end
|
package/src/AdBannerView.tsx
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
9
|
+
import {
|
|
10
|
+
findNodeHandle,
|
|
11
|
+
NativeModules,
|
|
12
|
+
requireNativeComponent,
|
|
13
|
+
UIManager,
|
|
14
|
+
View,
|
|
15
|
+
type DimensionValue,
|
|
16
|
+
type NativeMethods,
|
|
17
|
+
type ViewProps,
|
|
18
|
+
} from 'react-native';
|
|
19
|
+
import type {
|
|
20
|
+
AdBannerViewHandler,
|
|
21
|
+
AdBannerViewProps,
|
|
22
|
+
} from './types/AdBannerViewProps';
|
|
4
23
|
import type { AdNativeEvent } from './types/AdEvent';
|
|
5
24
|
import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
|
|
6
25
|
|
|
7
26
|
const { DaroMModule } = NativeModules;
|
|
8
27
|
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
MREC_AD_FORMAT_LABEL,
|
|
12
|
-
} = DaroMModule.getConstants();
|
|
28
|
+
const { BANNER_AD_FORMAT_LABEL, MREC_AD_FORMAT_LABEL } =
|
|
29
|
+
DaroMModule.getConstants();
|
|
13
30
|
|
|
14
31
|
export enum AdFormat {
|
|
15
32
|
BANNER = BANNER_AD_FORMAT_LABEL,
|
|
@@ -24,7 +41,9 @@ type AdViewNativeEvents = {
|
|
|
24
41
|
};
|
|
25
42
|
|
|
26
43
|
const ComponentName = 'DaroMAdBannerView';
|
|
27
|
-
const AdViewComponent = requireNativeComponent<
|
|
44
|
+
const AdViewComponent = requireNativeComponent<
|
|
45
|
+
AdBannerViewProps & ViewProps & AdViewNativeEvents
|
|
46
|
+
>(ComponentName);
|
|
28
47
|
type AdViewType = React.Component<AdBannerViewProps> & NativeMethods;
|
|
29
48
|
|
|
30
49
|
type SizeKey = 'width' | 'height';
|
|
@@ -35,7 +54,10 @@ const ADVIEW_SIZE = {
|
|
|
35
54
|
mrec: { width: 300, height: 250 },
|
|
36
55
|
};
|
|
37
56
|
|
|
38
|
-
export const AdBannerView = forwardRef<
|
|
57
|
+
export const AdBannerView = forwardRef<
|
|
58
|
+
AdBannerViewHandler,
|
|
59
|
+
AdBannerViewProps & ViewProps
|
|
60
|
+
>(function AdBannerView(
|
|
39
61
|
{
|
|
40
62
|
adUnitId,
|
|
41
63
|
adFormat,
|
|
@@ -51,18 +73,23 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
|
|
|
51
73
|
},
|
|
52
74
|
ref
|
|
53
75
|
) {
|
|
54
|
-
|
|
55
76
|
const adFormatSize = useRef<SizeRecord>({});
|
|
56
77
|
const adViewRef = useRef<AdViewType | null>(null);
|
|
57
78
|
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
58
79
|
|
|
59
80
|
const loadAd = useCallback(() => {
|
|
60
81
|
if (adViewRef.current) {
|
|
82
|
+
const nodeHandle = findNodeHandle(adViewRef.current);
|
|
83
|
+
|
|
84
|
+
if (typeof nodeHandle !== 'number') {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
61
88
|
UIManager.dispatchViewManagerCommand(
|
|
62
|
-
|
|
89
|
+
nodeHandle,
|
|
63
90
|
// @ts-ignore: Issue in RN ts defs
|
|
64
91
|
UIManager.getViewManagerConfig(ComponentName).Commands.loadAd,
|
|
65
|
-
[]
|
|
92
|
+
[]
|
|
66
93
|
);
|
|
67
94
|
}
|
|
68
95
|
}, []);
|
|
@@ -76,15 +103,23 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
|
|
|
76
103
|
useEffect(() => {
|
|
77
104
|
(async () => {
|
|
78
105
|
if (adFormat === AdFormat.BANNER) {
|
|
79
|
-
adFormatSize.current = {
|
|
106
|
+
adFormatSize.current = {
|
|
107
|
+
width: ADVIEW_SIZE.banner.width,
|
|
108
|
+
height: ADVIEW_SIZE.banner.height,
|
|
109
|
+
};
|
|
80
110
|
} else {
|
|
81
|
-
adFormatSize.current = {
|
|
111
|
+
adFormatSize.current = {
|
|
112
|
+
width: ADVIEW_SIZE.mrec.width,
|
|
113
|
+
height: ADVIEW_SIZE.mrec.height,
|
|
114
|
+
};
|
|
82
115
|
}
|
|
83
116
|
const initialized = await DaroMModule.isInitialized();
|
|
84
117
|
setIsInitialized(initialized);
|
|
85
118
|
|
|
86
119
|
if (!initialized) {
|
|
87
|
-
console.warn(
|
|
120
|
+
console.warn(
|
|
121
|
+
'AdBannerView is mounted before the initialization of the DaroM React Native module'
|
|
122
|
+
);
|
|
88
123
|
}
|
|
89
124
|
})();
|
|
90
125
|
}, [adFormat]);
|
|
@@ -130,11 +165,13 @@ export const AdBannerView = forwardRef<AdBannerViewHandler, AdBannerViewProps &
|
|
|
130
165
|
ref={saveElement}
|
|
131
166
|
adUnitId={adUnitId}
|
|
132
167
|
placement={placement}
|
|
168
|
+
loadOnMount={loadOnMount}
|
|
133
169
|
isVisible={isVisible}
|
|
134
170
|
onAdLoadedEvent={onAdLoadedEvent}
|
|
135
171
|
onAdLoadFailedEvent={onAdLoadFailedEvent}
|
|
136
172
|
onAdClickedEvent={onAdClickedEvent}
|
|
137
173
|
onAdImpressionRecordedEvent={onAdImpressionRecordedEvent}
|
|
138
|
-
{...otherProps}
|
|
174
|
+
{...otherProps}
|
|
175
|
+
/>
|
|
139
176
|
);
|
|
140
|
-
});
|
|
177
|
+
});
|