adwhale-sdk-react-native 2.7.100
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/AdwhaleSdkReactNative.podspec +20 -0
- package/LICENSE +20 -0
- package/README.md +121 -0
- package/android/build.gradle +135 -0
- package/android/gradle.properties +2 -0
- package/android/proguard-rules.pro +247 -0
- package/android/settings.gradle +71 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/adwhalesdkreactnative/AdwhaleSdkReactNativePackage.java +130 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNAdWhaleMediationAdSettingModule.java +64 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNAdWhaleMediationAdView.java +172 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNAdWhaleMediationCustomNativeAdView.java +197 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNAdWhaleMediationInterstitialAd.java +134 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNAdWhaleMediationLoggerModule.java +35 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNAdWhaleMediationRewardAd.java +151 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNAdWhaleMediationTemplateNativeAdView.java +317 -0
- package/android/src/main/java/com/adwhalesdkreactnative/RNWrapperView.java +48 -0
- package/android/src/main/res/layout/custom_native_ad_layout.xml +58 -0
- package/app.plugin.js +2 -0
- package/ios/AdwhaleSdkReactNative.h +5 -0
- package/ios/AdwhaleSdkReactNative.mm +21 -0
- package/lib/module/AdWhaleBannerView.js +20 -0
- package/lib/module/AdWhaleBannerView.js.map +1 -0
- package/lib/module/AdWhaleInterstitialAd.js +47 -0
- package/lib/module/AdWhaleInterstitialAd.js.map +1 -0
- package/lib/module/AdWhaleMediationSdk.js +48 -0
- package/lib/module/AdWhaleMediationSdk.js.map +1 -0
- package/lib/module/AdWhaleNativeCustomView.js +36 -0
- package/lib/module/AdWhaleNativeCustomView.js.map +1 -0
- package/lib/module/AdWhaleNativeTemplateView.js +40 -0
- package/lib/module/AdWhaleNativeTemplateView.js.map +1 -0
- package/lib/module/AdWhaleRewardAd.js +50 -0
- package/lib/module/AdWhaleRewardAd.js.map +1 -0
- package/lib/module/NativeAdwhaleSdkReactNative.js +5 -0
- package/lib/module/NativeAdwhaleSdkReactNative.js.map +1 -0
- package/lib/module/index.js +28 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/AdWhaleBannerView.d.ts +18 -0
- package/lib/typescript/src/AdWhaleBannerView.d.ts.map +1 -0
- package/lib/typescript/src/AdWhaleInterstitialAd.d.ts +19 -0
- package/lib/typescript/src/AdWhaleInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/src/AdWhaleMediationSdk.d.ts +17 -0
- package/lib/typescript/src/AdWhaleMediationSdk.d.ts.map +1 -0
- package/lib/typescript/src/AdWhaleNativeCustomView.d.ts +19 -0
- package/lib/typescript/src/AdWhaleNativeCustomView.d.ts.map +1 -0
- package/lib/typescript/src/AdWhaleNativeTemplateView.d.ts +40 -0
- package/lib/typescript/src/AdWhaleNativeTemplateView.d.ts.map +1 -0
- package/lib/typescript/src/AdWhaleRewardAd.d.ts +24 -0
- package/lib/typescript/src/AdWhaleRewardAd.d.ts.map +1 -0
- package/lib/typescript/src/NativeAdwhaleSdkReactNative.d.ts +7 -0
- package/lib/typescript/src/NativeAdwhaleSdkReactNative.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +168 -0
- package/plugin/index.js +16 -0
- package/react-native.config.js +30 -0
- package/src/AdWhaleBannerView.tsx +53 -0
- package/src/AdWhaleInterstitialAd.ts +93 -0
- package/src/AdWhaleMediationSdk.ts +93 -0
- package/src/AdWhaleNativeCustomView.tsx +87 -0
- package/src/AdWhaleNativeTemplateView.tsx +119 -0
- package/src/AdWhaleRewardAd.ts +106 -0
- package/src/NativeAdwhaleSdkReactNative.ts +7 -0
- package/src/index.ts +61 -0
package/package.json
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "adwhale-sdk-react-native",
|
|
3
|
+
"version": "2.7.100",
|
|
4
|
+
"description": "Adwhale SDK React Native library for integrating Adwhale advertising mediation SDK into React Native applications.",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"react-native": "./lib/module/index.js",
|
|
7
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"react-native": "./lib/module/index.js",
|
|
11
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
12
|
+
"source": "./src/index.ts",
|
|
13
|
+
"default": "./lib/module/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src",
|
|
19
|
+
"lib",
|
|
20
|
+
"android",
|
|
21
|
+
"ios",
|
|
22
|
+
"cpp",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"plugin",
|
|
26
|
+
"app.plugin.js",
|
|
27
|
+
"!ios/build",
|
|
28
|
+
"!android/build",
|
|
29
|
+
"!android/gradle",
|
|
30
|
+
"!android/gradlew",
|
|
31
|
+
"!android/gradlew.bat",
|
|
32
|
+
"!android/local.properties",
|
|
33
|
+
"!**/__tests__",
|
|
34
|
+
"!**/__fixtures__",
|
|
35
|
+
"!**/__mocks__",
|
|
36
|
+
"!**/.*"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"example": "yarn workspace adwhale-sdk-react-native-example",
|
|
40
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
41
|
+
"prepare": "bob build",
|
|
42
|
+
"typecheck": "tsc",
|
|
43
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
44
|
+
"release": "release-it --only-version",
|
|
45
|
+
"test": "jest"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"react-native",
|
|
49
|
+
"ios",
|
|
50
|
+
"android",
|
|
51
|
+
"adwhale",
|
|
52
|
+
"ads",
|
|
53
|
+
"mediation"
|
|
54
|
+
],
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "git+https://github.com/dev-adwhale/adwhale-sdk-react-native.git"
|
|
58
|
+
},
|
|
59
|
+
"author": "adwhale_sdk <adwhale_sdk@fsn.co.kr> (https://github.com/dev-adwhale)",
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/dev-adwhale/adwhale-sdk-react-native/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/dev-adwhale/adwhale-sdk-react-native#readme",
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"registry": "https://registry.npmjs.org/"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@eslint/compat": "^1.3.2",
|
|
70
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
71
|
+
"@eslint/js": "^9.35.0",
|
|
72
|
+
"@react-native-community/cli": "20.0.1",
|
|
73
|
+
"@react-native/babel-preset": "0.81.1",
|
|
74
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
75
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
76
|
+
"@types/jest": "^29.5.14",
|
|
77
|
+
"@types/react": "^19.1.0",
|
|
78
|
+
"del-cli": "^6.0.0",
|
|
79
|
+
"eslint": "^9.35.0",
|
|
80
|
+
"eslint-config-prettier": "^10.1.8",
|
|
81
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
82
|
+
"jest": "^29.7.0",
|
|
83
|
+
"prettier": "^2.8.8",
|
|
84
|
+
"react": "19.1.0",
|
|
85
|
+
"react-native": "0.81.1",
|
|
86
|
+
"react-native-builder-bob": "^0.40.16",
|
|
87
|
+
"release-it": "^19.0.4",
|
|
88
|
+
"turbo": "^2.5.6",
|
|
89
|
+
"typescript": "^5.9.2"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": "*",
|
|
93
|
+
"react-native": "*"
|
|
94
|
+
},
|
|
95
|
+
"workspaces": [
|
|
96
|
+
"example"
|
|
97
|
+
],
|
|
98
|
+
"packageManager": "yarn@4.11.0",
|
|
99
|
+
"react-native-builder-bob": {
|
|
100
|
+
"source": "src",
|
|
101
|
+
"output": "lib",
|
|
102
|
+
"targets": [
|
|
103
|
+
[
|
|
104
|
+
"module",
|
|
105
|
+
{
|
|
106
|
+
"esm": true
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
"typescript",
|
|
111
|
+
{
|
|
112
|
+
"project": "tsconfig.build.json"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"codegenConfig": {
|
|
118
|
+
"name": "AdwhaleSdkReactNativeSpec",
|
|
119
|
+
"type": "modules",
|
|
120
|
+
"jsSrcsDir": "src",
|
|
121
|
+
"android": {
|
|
122
|
+
"javaPackageName": "com.adwhalesdkreactnative"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"prettier": {
|
|
126
|
+
"quoteProps": "consistent",
|
|
127
|
+
"singleQuote": true,
|
|
128
|
+
"tabWidth": 2,
|
|
129
|
+
"trailingComma": "es5",
|
|
130
|
+
"useTabs": false
|
|
131
|
+
},
|
|
132
|
+
"release-it": {
|
|
133
|
+
"git": {
|
|
134
|
+
"commitMessage": "chore: release ${version}",
|
|
135
|
+
"tagName": "v${version}"
|
|
136
|
+
},
|
|
137
|
+
"npm": {
|
|
138
|
+
"publish": true
|
|
139
|
+
},
|
|
140
|
+
"github": {
|
|
141
|
+
"release": true
|
|
142
|
+
},
|
|
143
|
+
"plugins": {
|
|
144
|
+
"@release-it/conventional-changelog": {
|
|
145
|
+
"preset": {
|
|
146
|
+
"name": "angular"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"jest": {
|
|
152
|
+
"preset": "react-native",
|
|
153
|
+
"modulePathIgnorePatterns": [
|
|
154
|
+
"<rootDir>/example/node_modules",
|
|
155
|
+
"<rootDir>/lib/"
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
"create-react-native-library": {
|
|
159
|
+
"languages": "kotlin-objc",
|
|
160
|
+
"type": "turbo-module",
|
|
161
|
+
"tools": [
|
|
162
|
+
"eslint",
|
|
163
|
+
"release-it",
|
|
164
|
+
"jest"
|
|
165
|
+
],
|
|
166
|
+
"version": "0.55.1"
|
|
167
|
+
}
|
|
168
|
+
}
|
package/plugin/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// plugin/index.js
|
|
2
|
+
const { createRunOncePlugin } = require('@expo/config-plugins');
|
|
3
|
+
const pkg = require('../package.json');
|
|
4
|
+
|
|
5
|
+
// Expo config plugin (no-op)
|
|
6
|
+
// - Expo prebuild 시 호출되지만, 실제로는 config를 그대로 반환만 함.
|
|
7
|
+
const withAdwhaleSdkReactNative = (config, props = {}) => {
|
|
8
|
+
// 나중에 필요해지면 여기서 AndroidManifest / build.gradle 수정 로직만 추가하면 됨.
|
|
9
|
+
return config;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = createRunOncePlugin(
|
|
13
|
+
withAdwhaleSdkReactNative,
|
|
14
|
+
pkg.name,
|
|
15
|
+
pkg.version
|
|
16
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
dependencies: {
|
|
5
|
+
'adwhale-sdk-react-native': {
|
|
6
|
+
root: path.resolve(__dirname),
|
|
7
|
+
platforms: {
|
|
8
|
+
android: {
|
|
9
|
+
sourceDir: path.join(__dirname, 'android'),
|
|
10
|
+
},
|
|
11
|
+
ios: {
|
|
12
|
+
// iOS는 나중에 구현할 예정이라면 비워둬도 됨
|
|
13
|
+
// podspec이 있으므로 autolinking은 자동됨
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// TurboModule codegen 위치 지정
|
|
20
|
+
project: {
|
|
21
|
+
android: {
|
|
22
|
+
// Optional—없어도 되지만 넣어두면 안전함
|
|
23
|
+
},
|
|
24
|
+
ios: {
|
|
25
|
+
// Optional
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
assets: [],
|
|
30
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/AdWhaleBannerView.tsx
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { requireNativeComponent } from 'react-native';
|
|
4
|
+
import type { NativeSyntheticEvent, StyleProp, ViewStyle } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export type AdWhaleBannerSize =
|
|
7
|
+
| '320x50'
|
|
8
|
+
| '320x100'
|
|
9
|
+
| '300x250'
|
|
10
|
+
| '250x250'
|
|
11
|
+
| 'ADAPTIVE_ANCHOR';
|
|
12
|
+
|
|
13
|
+
export interface AdWhaleBannerError {
|
|
14
|
+
statusCode: number;
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AdWhaleBannerViewProps {
|
|
19
|
+
style?: StyleProp<ViewStyle>;
|
|
20
|
+
placementUid: string;
|
|
21
|
+
adSize: AdWhaleBannerSize;
|
|
22
|
+
loadAd?: boolean;
|
|
23
|
+
|
|
24
|
+
onAdLoaded?: () => void;
|
|
25
|
+
onAdLoadFailed?: (event: AdWhaleBannerError) => void;
|
|
26
|
+
onAdClicked?: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type NativeErrorEvent = NativeSyntheticEvent<AdWhaleBannerError>;
|
|
30
|
+
|
|
31
|
+
interface NativeAdViewProps
|
|
32
|
+
extends Omit<AdWhaleBannerViewProps, 'onAdLoadFailed'> {
|
|
33
|
+
onAdLoadFailed?: (e: NativeErrorEvent) => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const RNAdWhaleMediationAdView =
|
|
37
|
+
requireNativeComponent<NativeAdViewProps>('RNAdWhaleMediationAdView');
|
|
38
|
+
|
|
39
|
+
export const AdWhaleBannerView: React.FC<AdWhaleBannerViewProps> = ({
|
|
40
|
+
onAdLoadFailed,
|
|
41
|
+
...restProps
|
|
42
|
+
}) => {
|
|
43
|
+
const handleAdLoadFailed: NativeAdViewProps['onAdLoadFailed'] = e => {
|
|
44
|
+
onAdLoadFailed?.(e.nativeEvent);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<RNAdWhaleMediationAdView
|
|
49
|
+
{...restProps}
|
|
50
|
+
onAdLoadFailed={onAdLoadFailed ? handleAdLoadFailed : undefined}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/AdWhaleInterstitialAd.ts
|
|
2
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
3
|
+
import type { EmitterSubscription } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export interface AdWhaleInterstitialErrorEvent {
|
|
6
|
+
statusCode: number;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface AdWhaleInterstitialEvents {
|
|
11
|
+
onLoaded?: () => void;
|
|
12
|
+
onLoadFailed?: (event: AdWhaleInterstitialErrorEvent) => void;
|
|
13
|
+
onShowed?: () => void;
|
|
14
|
+
onShowFailed?: (event: AdWhaleInterstitialErrorEvent) => void;
|
|
15
|
+
onClosed?: () => void;
|
|
16
|
+
onClicked?: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface RNAdWhaleMediationInterstitialAdNativeModule {
|
|
20
|
+
loadAd(placementUid: string): void;
|
|
21
|
+
showAd(): void;
|
|
22
|
+
addListener(eventName: string): void;
|
|
23
|
+
removeListeners(count: number): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { RNAdWhaleMediationInterstitialAd } = NativeModules as {
|
|
27
|
+
RNAdWhaleMediationInterstitialAd: RNAdWhaleMediationInterstitialAdNativeModule;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const interstitialEmitter = new NativeEventEmitter(
|
|
31
|
+
RNAdWhaleMediationInterstitialAd,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export const AdWhaleInterstitialAd = {
|
|
35
|
+
loadAd(placementUid: string) {
|
|
36
|
+
RNAdWhaleMediationInterstitialAd.loadAd(placementUid);
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
showAd() {
|
|
40
|
+
RNAdWhaleMediationInterstitialAd.showAd();
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
addEventListeners(listeners: AdWhaleInterstitialEvents): EmitterSubscription[] {
|
|
44
|
+
const subs: EmitterSubscription[] = [];
|
|
45
|
+
|
|
46
|
+
if (listeners.onLoaded) {
|
|
47
|
+
subs.push(
|
|
48
|
+
interstitialEmitter.addListener('onInterstitialAdLoaded', () => {
|
|
49
|
+
listeners.onLoaded?.();
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (listeners.onLoadFailed) {
|
|
54
|
+
subs.push(
|
|
55
|
+
interstitialEmitter.addListener(
|
|
56
|
+
'onInterstitialAdLoadFailed',
|
|
57
|
+
event => listeners.onLoadFailed?.(event as AdWhaleInterstitialErrorEvent),
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (listeners.onShowed) {
|
|
62
|
+
subs.push(
|
|
63
|
+
interstitialEmitter.addListener('onInterstitialAdShowed', () => {
|
|
64
|
+
listeners.onShowed?.();
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (listeners.onShowFailed) {
|
|
69
|
+
subs.push(
|
|
70
|
+
interstitialEmitter.addListener(
|
|
71
|
+
'onInterstitialAdShowFailed',
|
|
72
|
+
event => listeners.onShowFailed?.(event as AdWhaleInterstitialErrorEvent),
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (listeners.onClosed) {
|
|
77
|
+
subs.push(
|
|
78
|
+
interstitialEmitter.addListener('onInterstitialAdClosed', () => {
|
|
79
|
+
listeners.onClosed?.();
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
if (listeners.onClicked) {
|
|
84
|
+
subs.push(
|
|
85
|
+
interstitialEmitter.addListener('onInterstitialAdClicked', () => {
|
|
86
|
+
listeners.onClicked?.();
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return subs;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/AdWhaleMediationSdk.ts
|
|
2
|
+
import { NativeModules, Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const LINKING_ERROR =
|
|
5
|
+
`AdWhale Mediation SDK native modules not linked.\n` +
|
|
6
|
+
`Make sure:\n` +
|
|
7
|
+
` • Android: AdwhaleSdkReactNative / RNAdWhaleMediationLoggerModule 등록 여부\n` +
|
|
8
|
+
` • iOS: Pod install 및 빌드 완료 여부\n` +
|
|
9
|
+
` • Web 환경에서 실행 중이 아닌지\n` +
|
|
10
|
+
`Platform: ${Platform.OS}`;
|
|
11
|
+
|
|
12
|
+
// 네이티브 이름에 맞게 수정 👇
|
|
13
|
+
interface AdwhaleSdkReactNativeModule {
|
|
14
|
+
initialize(): Promise<number>;
|
|
15
|
+
|
|
16
|
+
// 아래 메서드들은 네이티브에 없으면 자동으로 undefined라서
|
|
17
|
+
// JS에서 optional로 안전하게 처리됨
|
|
18
|
+
setCoppa?(enabled: boolean): void;
|
|
19
|
+
requestGdprConsent?(): Promise<{
|
|
20
|
+
isSuccess: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
}>;
|
|
23
|
+
getConsentStatus?(): Promise<{
|
|
24
|
+
coppa: boolean;
|
|
25
|
+
gdpr: string;
|
|
26
|
+
personalizedConsent: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
resetGdprConsentStatus?(): void;
|
|
29
|
+
setGdpr?(consent: boolean): void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface RNAdWhaleMediationLoggerModule {
|
|
33
|
+
setLogLevel?(enabled: boolean): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
AdwhaleSdkReactNative,
|
|
38
|
+
RNAdWhaleMediationLoggerModule,
|
|
39
|
+
} = NativeModules as {
|
|
40
|
+
AdwhaleSdkReactNative?: AdwhaleSdkReactNativeModule;
|
|
41
|
+
RNAdWhaleMediationLoggerModule?: RNAdWhaleMediationLoggerModule;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (!AdwhaleSdkReactNative) {
|
|
45
|
+
console.warn(LINKING_ERROR);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const AdWhaleMediationSdk = {
|
|
49
|
+
initialize(): Promise<number> {
|
|
50
|
+
if (!AdwhaleSdkReactNative?.initialize) {
|
|
51
|
+
return Promise.reject(new Error(LINKING_ERROR));
|
|
52
|
+
}
|
|
53
|
+
return AdwhaleSdkReactNative.initialize();
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
setLoggerEnabled(enabled: boolean) {
|
|
57
|
+
RNAdWhaleMediationLoggerModule?.setLogLevel?.(enabled);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
setCoppa(enabled: boolean) {
|
|
61
|
+
AdwhaleSdkReactNative?.setCoppa?.(enabled);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
requestGdprConsent(): Promise<{ isSuccess: boolean; message: string }> {
|
|
65
|
+
if (!AdwhaleSdkReactNative?.requestGdprConsent) {
|
|
66
|
+
return Promise.reject(
|
|
67
|
+
new Error('requestGdprConsent is not implemented in native module'),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return AdwhaleSdkReactNative.requestGdprConsent();
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
getConsentStatus(): Promise<{
|
|
74
|
+
coppa: boolean;
|
|
75
|
+
gdpr: string;
|
|
76
|
+
personalizedConsent: boolean;
|
|
77
|
+
}> {
|
|
78
|
+
if (!AdwhaleSdkReactNative?.getConsentStatus) {
|
|
79
|
+
return Promise.reject(
|
|
80
|
+
new Error('getConsentStatus is not implemented in native module'),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return AdwhaleSdkReactNative.getConsentStatus();
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
resetGdprConsentStatus() {
|
|
87
|
+
AdwhaleSdkReactNative?.resetGdprConsentStatus?.();
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
setGdpr(consent: boolean) {
|
|
91
|
+
AdwhaleSdkReactNative?.setGdpr?.(consent);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/AdWhaleNativeCustomView.tsx
|
|
2
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import { requireNativeComponent, UIManager, findNodeHandle } from 'react-native';
|
|
4
|
+
import type {
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
StyleProp,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
export interface AdWhaleNativeCustomError {
|
|
11
|
+
errorCode: number;
|
|
12
|
+
errorMessage: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface AdWhaleNativeCustomViewProps {
|
|
16
|
+
style?: StyleProp<ViewStyle>;
|
|
17
|
+
placementUid: string;
|
|
18
|
+
layoutName: string;
|
|
19
|
+
|
|
20
|
+
onAdLoaded?: () => void;
|
|
21
|
+
onAdFailedToLoad?: (event: AdWhaleNativeCustomError) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface AdWhaleNativeCustomHandle {
|
|
25
|
+
loadAd(): void;
|
|
26
|
+
showAd(): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type NativeErrorEvent = NativeSyntheticEvent<AdWhaleNativeCustomError>;
|
|
30
|
+
|
|
31
|
+
interface NativeProps
|
|
32
|
+
extends Omit<AdWhaleNativeCustomViewProps, 'onAdFailedToLoad'> {
|
|
33
|
+
onAdFailedToLoad?: (e: NativeErrorEvent) => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const VIEW_MANAGER_NAME = 'RNAdWhaleMediationCustomNativeAdView';
|
|
37
|
+
|
|
38
|
+
const NativeComponent =
|
|
39
|
+
requireNativeComponent<NativeProps>(VIEW_MANAGER_NAME);
|
|
40
|
+
|
|
41
|
+
export const AdWhaleNativeCustomView = forwardRef<
|
|
42
|
+
AdWhaleNativeCustomHandle,
|
|
43
|
+
AdWhaleNativeCustomViewProps
|
|
44
|
+
>((props, ref) => {
|
|
45
|
+
const innerRef = useRef<React.ElementRef<typeof NativeComponent>>(null);
|
|
46
|
+
|
|
47
|
+
useImperativeHandle(ref, () => ({
|
|
48
|
+
loadAd() {
|
|
49
|
+
const handle = findNodeHandle(innerRef.current);
|
|
50
|
+
if (!handle) return;
|
|
51
|
+
const config = UIManager.getViewManagerConfig(VIEW_MANAGER_NAME) as
|
|
52
|
+
| { Commands?: { loadAd?: number; showAd?: number } }
|
|
53
|
+
| undefined;
|
|
54
|
+
if (!config?.Commands?.loadAd) return;
|
|
55
|
+
UIManager.dispatchViewManagerCommand(
|
|
56
|
+
handle,
|
|
57
|
+
config.Commands.loadAd,
|
|
58
|
+
[],
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
showAd() {
|
|
62
|
+
const handle = findNodeHandle(innerRef.current);
|
|
63
|
+
if (!handle) return;
|
|
64
|
+
const config = UIManager.getViewManagerConfig(VIEW_MANAGER_NAME) as
|
|
65
|
+
| { Commands?: { loadAd?: number; showAd?: number } }
|
|
66
|
+
| undefined;
|
|
67
|
+
if (!config?.Commands?.showAd) return;
|
|
68
|
+
UIManager.dispatchViewManagerCommand(
|
|
69
|
+
handle,
|
|
70
|
+
config.Commands.showAd,
|
|
71
|
+
[],
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
const handleFailedToLoad: NativeProps['onAdFailedToLoad'] = e => {
|
|
77
|
+
props.onAdFailedToLoad?.(e.nativeEvent);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<NativeComponent
|
|
82
|
+
ref={innerRef}
|
|
83
|
+
{...props}
|
|
84
|
+
onAdFailedToLoad={props.onAdFailedToLoad ? handleFailedToLoad : undefined}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// src/AdWhaleNativeTemplateView.tsx
|
|
2
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import { requireNativeComponent, UIManager, findNodeHandle } from 'react-native';
|
|
4
|
+
import type {
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
StyleProp,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
export type AdWhaleNativeTemplateType = 'SMALL' | 'MEDIUM';
|
|
11
|
+
|
|
12
|
+
export interface AdWhaleNativeTemplateStyle {
|
|
13
|
+
mainBackgroundColor?: string;
|
|
14
|
+
primaryTextTypefaceColor?: string;
|
|
15
|
+
primaryTextSize?: number;
|
|
16
|
+
primaryTextBackgroundColor?: string;
|
|
17
|
+
secondaryTextTypefaceColor?: string;
|
|
18
|
+
secondaryTextSize?: number;
|
|
19
|
+
secondaryTextBackgroundColor?: string;
|
|
20
|
+
tertiaryTextTypefaceColor?: string;
|
|
21
|
+
tertiaryTextSize?: number;
|
|
22
|
+
tertiaryTextBackgroundColor?: string;
|
|
23
|
+
callToActionTypefaceColor?: string;
|
|
24
|
+
callToActionTextSize?: number;
|
|
25
|
+
callToActionBackgroundColor?: string;
|
|
26
|
+
primaryTextTypeface?: 'bold' | 'italic';
|
|
27
|
+
secondaryTextTypeface?: 'bold' | 'italic';
|
|
28
|
+
callToActionTextTypeface?: 'bold' | 'italic';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AdWhaleNativeTemplateError {
|
|
32
|
+
errorCode: number;
|
|
33
|
+
errorMessage: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AdWhaleNativeTemplateViewProps {
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
placementUid: string;
|
|
39
|
+
template: AdWhaleNativeTemplateType;
|
|
40
|
+
templateStyle?: AdWhaleNativeTemplateStyle;
|
|
41
|
+
|
|
42
|
+
onAdLoaded?: () => void;
|
|
43
|
+
onAdFailedToLoad?: (event: AdWhaleNativeTemplateError) => void;
|
|
44
|
+
onAdShowFailed?: (event: AdWhaleNativeTemplateError) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AdWhaleNativeTemplateHandle {
|
|
48
|
+
loadAd(): void;
|
|
49
|
+
showAd(): void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type NativeErrorEvent = NativeSyntheticEvent<AdWhaleNativeTemplateError>;
|
|
53
|
+
|
|
54
|
+
interface NativeProps
|
|
55
|
+
extends Omit<
|
|
56
|
+
AdWhaleNativeTemplateViewProps,
|
|
57
|
+
'onAdFailedToLoad' | 'onAdShowFailed'
|
|
58
|
+
> {
|
|
59
|
+
onAdFailedToLoad?: (e: NativeErrorEvent) => void;
|
|
60
|
+
onAdShowFailed?: (e: NativeErrorEvent) => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const VIEW_MANAGER_NAME = 'RNAdWhaleMediationTemplateNativeAdView';
|
|
64
|
+
|
|
65
|
+
const NativeComponent =
|
|
66
|
+
requireNativeComponent<NativeProps>(VIEW_MANAGER_NAME);
|
|
67
|
+
|
|
68
|
+
export const AdWhaleNativeTemplateView = forwardRef<
|
|
69
|
+
AdWhaleNativeTemplateHandle,
|
|
70
|
+
AdWhaleNativeTemplateViewProps
|
|
71
|
+
>((props, ref) => {
|
|
72
|
+
const innerRef = useRef<React.ElementRef<typeof NativeComponent>>(null);
|
|
73
|
+
|
|
74
|
+
useImperativeHandle(ref, () => ({
|
|
75
|
+
loadAd() {
|
|
76
|
+
const handle = findNodeHandle(innerRef.current);
|
|
77
|
+
if (!handle) return;
|
|
78
|
+
const config = UIManager.getViewManagerConfig(VIEW_MANAGER_NAME) as
|
|
79
|
+
| { Commands?: { loadAd?: number; showAd?: number } }
|
|
80
|
+
| undefined;
|
|
81
|
+
if (!config?.Commands?.loadAd) return;
|
|
82
|
+
UIManager.dispatchViewManagerCommand(
|
|
83
|
+
handle,
|
|
84
|
+
config.Commands.loadAd,
|
|
85
|
+
[],
|
|
86
|
+
);
|
|
87
|
+
},
|
|
88
|
+
showAd() {
|
|
89
|
+
const handle = findNodeHandle(innerRef.current);
|
|
90
|
+
if (!handle) return;
|
|
91
|
+
const config = UIManager.getViewManagerConfig(VIEW_MANAGER_NAME) as
|
|
92
|
+
| { Commands?: { loadAd?: number; showAd?: number } }
|
|
93
|
+
| undefined;
|
|
94
|
+
if (!config?.Commands?.showAd) return;
|
|
95
|
+
UIManager.dispatchViewManagerCommand(
|
|
96
|
+
handle,
|
|
97
|
+
config.Commands.showAd,
|
|
98
|
+
[],
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
const handleFailedToLoad: NativeProps['onAdFailedToLoad'] = e => {
|
|
104
|
+
props.onAdFailedToLoad?.(e.nativeEvent);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const handleShowFailed: NativeProps['onAdShowFailed'] = e => {
|
|
108
|
+
props.onAdShowFailed?.(e.nativeEvent);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<NativeComponent
|
|
113
|
+
ref={innerRef}
|
|
114
|
+
{...props}
|
|
115
|
+
onAdFailedToLoad={props.onAdFailedToLoad ? handleFailedToLoad : undefined}
|
|
116
|
+
onAdShowFailed={props.onAdShowFailed ? handleShowFailed : undefined}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
});
|