@1selfworld/adchain-sdk-react-native 1.0.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/LICENSE +20 -0
- package/README.md +211 -0
- package/adchain-sdk-react-native.podspec +25 -0
- package/android/build.gradle +38 -0
- package/android/src/main/java/com/adchain/exposdk/AdchainOfferwallViewManager.kt +288 -0
- package/android/src/main/java/com/adchain/exposdk/AdchainSdkModule.kt +742 -0
- package/android/src/main/java/com/adchain/exposdk/AdchainSdkPackage.kt +14 -0
- package/app.plugin.js +17 -0
- package/ios/AdchainOfferwallViewManager.m +17 -0
- package/ios/AdchainOfferwallViewManager.swift +242 -0
- package/ios/AdchainSdk.m +87 -0
- package/ios/AdchainSdk.swift +792 -0
- package/lib/module/index.js +162 -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/index.d.ts +88 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +153 -0
- package/plugin/src/withAdchainAndroid.js +56 -0
- package/plugin/src/withAdchainConfig.js +22 -0
- package/plugin/src/withAdchainIOS.js +60 -0
- package/react-native.config.js +8 -0
- package/src/index.tsx +274 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules, Platform, NativeEventEmitter } from 'react-native';
|
|
4
|
+
import Constants from 'expo-constants';
|
|
5
|
+
const LINKING_ERROR = `The package 'adchain-sdk' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
6
|
+
ios: "- You have run 'pod install'\n",
|
|
7
|
+
default: ''
|
|
8
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
9
|
+
const AdchainSdk = NativeModules.AdchainSdk ? NativeModules.AdchainSdk : new Proxy({}, {
|
|
10
|
+
get() {
|
|
11
|
+
throw new Error(LINKING_ERROR);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Event Emitter 생성
|
|
16
|
+
const adchainEventEmitter = new NativeEventEmitter(AdchainSdk);
|
|
17
|
+
|
|
18
|
+
// ===== Type Definitions =====
|
|
19
|
+
|
|
20
|
+
// ===== SDK Class =====
|
|
21
|
+
|
|
22
|
+
class AdchainSDK {
|
|
23
|
+
// 1. SDK 초기화
|
|
24
|
+
async initialize(config) {
|
|
25
|
+
// options 객체로 environment와 timeout 전달
|
|
26
|
+
const options = {
|
|
27
|
+
environment: config.environment,
|
|
28
|
+
timeout: config.timeout
|
|
29
|
+
};
|
|
30
|
+
return AdchainSdk.initialize(config.appKey, config.appSecret, options);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Expo용 자동 초기화 (app.json 설정 사용) - 플랫폼별 credentials 지원
|
|
34
|
+
async autoInitialize() {
|
|
35
|
+
try {
|
|
36
|
+
const expoConfig = Constants.expoConfig;
|
|
37
|
+
if (!expoConfig) {
|
|
38
|
+
throw new Error('AdChain: Expo config not found. ' + 'Are you running in Expo Go? This SDK requires a development build. ' + 'Please use: npx expo run:android or npx expo run:ios');
|
|
39
|
+
}
|
|
40
|
+
const {
|
|
41
|
+
adchainAndroidAppKey,
|
|
42
|
+
adchainAndroidAppSecret,
|
|
43
|
+
adchainIosAppKey,
|
|
44
|
+
adchainIosAppSecret,
|
|
45
|
+
adchainEnvironment,
|
|
46
|
+
adchainTimeout
|
|
47
|
+
} = expoConfig.extra || {};
|
|
48
|
+
|
|
49
|
+
// 플랫폼별 credentials 선택
|
|
50
|
+
const isIOS = Platform.OS === 'ios';
|
|
51
|
+
const appKey = isIOS ? adchainIosAppKey : adchainAndroidAppKey;
|
|
52
|
+
const appSecret = isIOS ? adchainIosAppSecret : adchainAndroidAppSecret;
|
|
53
|
+
if (!appKey || !appSecret) {
|
|
54
|
+
throw new Error(`AdChain: Missing ${Platform.OS} configuration in app.json. ` + 'Please add AdChain SDK to plugins section:\n\n' + '{\n' + ' "expo": {\n' + ' "plugins": [\n' + ' ["@adchain/expo-sdk", {\n' + ' "android": {\n' + ' "appKey": "YOUR_ANDROID_APP_KEY",\n' + ' "appSecret": "YOUR_APP_SECRET"\n' + ' },\n' + ' "ios": {\n' + ' "appKey": "YOUR_IOS_APP_KEY",\n' + ' "appSecret": "YOUR_APP_SECRET"\n' + ' }\n' + ' }]\n' + ' ]\n' + ' }\n' + '}');
|
|
55
|
+
}
|
|
56
|
+
console.log(`[AdChain] Auto-initializing with ${Platform.OS} credentials...`);
|
|
57
|
+
return await this.initialize({
|
|
58
|
+
appKey,
|
|
59
|
+
appSecret,
|
|
60
|
+
environment: adchainEnvironment || 'PRODUCTION',
|
|
61
|
+
timeout: adchainTimeout
|
|
62
|
+
});
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('[AdChain autoInitialize] Failed:', error);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 2. 인증 관련 (4개)
|
|
70
|
+
async login(user) {
|
|
71
|
+
// userInfo 객체로 모든 정보 전달
|
|
72
|
+
const userInfo = {
|
|
73
|
+
gender: user.gender,
|
|
74
|
+
birthYear: user.birthYear,
|
|
75
|
+
customProperties: user.customProperties
|
|
76
|
+
};
|
|
77
|
+
return AdchainSdk.login(user.userId, userInfo);
|
|
78
|
+
}
|
|
79
|
+
async logout() {
|
|
80
|
+
return AdchainSdk.logout();
|
|
81
|
+
}
|
|
82
|
+
async isLoggedIn() {
|
|
83
|
+
return AdchainSdk.isLoggedIn();
|
|
84
|
+
}
|
|
85
|
+
async getCurrentUser() {
|
|
86
|
+
return AdchainSdk.getCurrentUser();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 3. Quiz 관련 (2개)
|
|
90
|
+
async loadQuizList(unitId) {
|
|
91
|
+
return AdchainSdk.loadQuizList(unitId);
|
|
92
|
+
}
|
|
93
|
+
async clickQuiz(unitId, quizId) {
|
|
94
|
+
return AdchainSdk.clickQuiz(unitId, quizId);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 4. Mission 관련 (3개)
|
|
98
|
+
async loadMissionList(unitId) {
|
|
99
|
+
return AdchainSdk.loadMissionList(unitId);
|
|
100
|
+
}
|
|
101
|
+
async clickMission(unitId, missionId) {
|
|
102
|
+
return AdchainSdk.clickMission(unitId, missionId);
|
|
103
|
+
}
|
|
104
|
+
async claimReward(unitId) {
|
|
105
|
+
return AdchainSdk.claimReward(unitId);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 5. Offerwall (3개)
|
|
109
|
+
async openOfferwall(placementId) {
|
|
110
|
+
// SDK requires placementId, use empty string if not provided
|
|
111
|
+
return AdchainSdk.openOfferwall(placementId || "");
|
|
112
|
+
}
|
|
113
|
+
async openOfferwallWithUrl(url, placementId) {
|
|
114
|
+
// SDK requires placementId, use empty string if not provided
|
|
115
|
+
return AdchainSdk.openOfferwallWithUrl(url, placementId || "");
|
|
116
|
+
}
|
|
117
|
+
async openExternalBrowser(url, placementId) {
|
|
118
|
+
// SDK requires placementId, use empty string if not provided
|
|
119
|
+
return AdchainSdk.openExternalBrowser(url, placementId || "");
|
|
120
|
+
}
|
|
121
|
+
async openAdjoeOfferwall(placementId) {
|
|
122
|
+
// SDK requires placementId, use empty string if not provided
|
|
123
|
+
return AdchainSdk.openAdjoeOfferwall(placementId || "");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// 6. Debug/Utility Methods (3개)
|
|
127
|
+
async isInitialized() {
|
|
128
|
+
return AdchainSdk.isInitialized();
|
|
129
|
+
}
|
|
130
|
+
async getUserId() {
|
|
131
|
+
return AdchainSdk.getUserId();
|
|
132
|
+
}
|
|
133
|
+
async getIFA() {
|
|
134
|
+
return AdchainSdk.getIFA();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 7. Banner (1개)
|
|
138
|
+
async getBannerInfo(placementId) {
|
|
139
|
+
return AdchainSdk.getBannerInfo(placementId);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ===== Event Helper Functions =====
|
|
144
|
+
|
|
145
|
+
export function addQuizCompletedListener(callback) {
|
|
146
|
+
return adchainEventEmitter.addListener('onQuizCompleted', callback);
|
|
147
|
+
}
|
|
148
|
+
export function addMissionCompletedListener(callback) {
|
|
149
|
+
return adchainEventEmitter.addListener('onMissionCompleted', callback);
|
|
150
|
+
}
|
|
151
|
+
export function addMissionProgressedListener(callback) {
|
|
152
|
+
return adchainEventEmitter.addListener('onMissionProgressed', callback);
|
|
153
|
+
}
|
|
154
|
+
export function addMissionRefreshedListener(callback) {
|
|
155
|
+
return adchainEventEmitter.addListener('onMissionRefreshed', callback);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ===== Export =====
|
|
159
|
+
|
|
160
|
+
const sdk = new AdchainSDK();
|
|
161
|
+
export default sdk;
|
|
162
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","NativeEventEmitter","Constants","LINKING_ERROR","select","ios","default","AdchainSdk","Proxy","get","Error","adchainEventEmitter","AdchainSDK","initialize","config","options","environment","timeout","appKey","appSecret","autoInitialize","expoConfig","adchainAndroidAppKey","adchainAndroidAppSecret","adchainIosAppKey","adchainIosAppSecret","adchainEnvironment","adchainTimeout","extra","isIOS","OS","console","log","error","login","user","userInfo","gender","birthYear","customProperties","userId","logout","isLoggedIn","getCurrentUser","loadQuizList","unitId","clickQuiz","quizId","loadMissionList","clickMission","missionId","claimReward","openOfferwall","placementId","openOfferwallWithUrl","url","openExternalBrowser","openAdjoeOfferwall","isInitialized","getUserId","getIFA","getBannerInfo","addQuizCompletedListener","callback","addListener","addMissionCompletedListener","addMissionProgressedListener","addMissionRefreshedListener","sdk"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,QAAQ,EAAEC,kBAAkB,QAAQ,cAAc;AAC1E,OAAOC,SAAS,MAA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ACtC,OAAOnD,UAAU,CAACmD,aAAa,CAAC,CAAC;EACnC;EAEA,MAAMC,SAASA,CAAA,EAAoB;IACjC,OAAOpD,UAAU,CAACoD,SAAS,CAAC,CAAC;EAC/B;EAEA,MAAMC,MAAMA,CAAA,EAAoB;IAC9B,OAAOrD,UAAU,CAACqD,MAAM,CAAC,CAAC;EAC5B;;EAEA;EACA,MAAMC,aAAaA,CAACR,WAAmB,EAAgB;IACrD,OAAO9C,UAAU,CAACsD,aAAa,CAACR,WAAW,CAAC;EAC9C;AACF;;AAEA;;AAEA,OAAO,SAASS,wBAAwBA,CAACC,QAA6D,EAAE;EACtG,OAAOpD,mBAAmB,CAACqD,WAAW,CAAC,iBAAiB,EAAED,QAAe,CAAC;AAC5E;AAEA,OAAO,SAASE,2BAA2BA,CAACF,QAAgE,EAAE;EAC5G,OAAOpD,mBAAmB,CAACqD,WAAW,CAAC,oBAAoB,EAAED,QAAe,CAAC;AAC/E;AAEA,OAAO,SAASG,4BAA4BA,CAACH,QAAgE,EAAE;EAC7G,OAAOpD,mBAAmB,CAACqD,WAAW,CAAC,qBAAqB,EAAED,QAAe,CAAC;AAChF;AAEA,OAAO,SAASI,2BAA2BA,CAACJ,QAA6C,EAAE;EACzF,OAAOpD,mBAAmB,CAACqD,WAAW,CAAC,oBAAoB,EAAED,QAAe,CAAC;AAC/E;;AAEA;;AAEA,MAAMK,GAAG,GAAG,IAAIxD,UAAU,CAAC,CAAC;AAC5B,eAAewD,GAAG","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export interface AdchainConfig {
|
|
2
|
+
appKey: string;
|
|
3
|
+
appSecret: string;
|
|
4
|
+
environment?: 'PRODUCTION' | 'STAGING' | 'DEVELOPMENT';
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface AdchainUser {
|
|
8
|
+
userId: string;
|
|
9
|
+
gender?: 'MALE' | 'FEMALE' | 'OTHER' | 'M' | 'F';
|
|
10
|
+
birthYear?: number;
|
|
11
|
+
customProperties?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface Quiz {
|
|
14
|
+
id: string;
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
imageUrl: string;
|
|
18
|
+
reward: number;
|
|
19
|
+
isCompleted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface QuizResponse {
|
|
22
|
+
success: boolean;
|
|
23
|
+
titleText?: string;
|
|
24
|
+
completedImageUrl?: string;
|
|
25
|
+
completedImageWidth?: number;
|
|
26
|
+
completedImageHeight?: number;
|
|
27
|
+
events: Quiz[];
|
|
28
|
+
message?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Mission {
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
description: string;
|
|
34
|
+
imageUrl: string;
|
|
35
|
+
reward: number;
|
|
36
|
+
isCompleted: boolean;
|
|
37
|
+
type: string;
|
|
38
|
+
actionUrl: string;
|
|
39
|
+
}
|
|
40
|
+
export interface MissionListResponse {
|
|
41
|
+
missions: Mission[];
|
|
42
|
+
completedCount: number;
|
|
43
|
+
totalCount: number;
|
|
44
|
+
canClaimReward: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface SuccessResponse {
|
|
47
|
+
success: boolean;
|
|
48
|
+
message: string;
|
|
49
|
+
}
|
|
50
|
+
declare class AdchainSDK {
|
|
51
|
+
initialize(config: AdchainConfig): Promise<SuccessResponse>;
|
|
52
|
+
autoInitialize(): Promise<SuccessResponse>;
|
|
53
|
+
login(user: AdchainUser): Promise<SuccessResponse>;
|
|
54
|
+
logout(): Promise<SuccessResponse>;
|
|
55
|
+
isLoggedIn(): Promise<boolean>;
|
|
56
|
+
getCurrentUser(): Promise<AdchainUser | null>;
|
|
57
|
+
loadQuizList(unitId: string): Promise<QuizResponse>;
|
|
58
|
+
clickQuiz(unitId: string, quizId: string): Promise<SuccessResponse>;
|
|
59
|
+
loadMissionList(unitId: string): Promise<MissionListResponse>;
|
|
60
|
+
clickMission(unitId: string, missionId: string): Promise<SuccessResponse>;
|
|
61
|
+
claimReward(unitId: string): Promise<SuccessResponse>;
|
|
62
|
+
openOfferwall(placementId?: string): Promise<SuccessResponse>;
|
|
63
|
+
openOfferwallWithUrl(url: string, placementId?: string): Promise<SuccessResponse>;
|
|
64
|
+
openExternalBrowser(url: string, placementId?: string): Promise<SuccessResponse>;
|
|
65
|
+
openAdjoeOfferwall(placementId?: string): Promise<SuccessResponse>;
|
|
66
|
+
isInitialized(): Promise<boolean>;
|
|
67
|
+
getUserId(): Promise<string>;
|
|
68
|
+
getIFA(): Promise<string>;
|
|
69
|
+
getBannerInfo(placementId: string): Promise<any>;
|
|
70
|
+
}
|
|
71
|
+
export declare function addQuizCompletedListener(callback: (event: {
|
|
72
|
+
quizId: string;
|
|
73
|
+
unitId: string;
|
|
74
|
+
}) => void): import("react-native").EventSubscription;
|
|
75
|
+
export declare function addMissionCompletedListener(callback: (event: {
|
|
76
|
+
missionId: string;
|
|
77
|
+
unitId: string;
|
|
78
|
+
}) => void): import("react-native").EventSubscription;
|
|
79
|
+
export declare function addMissionProgressedListener(callback: (event: {
|
|
80
|
+
missionId: string;
|
|
81
|
+
unitId: string;
|
|
82
|
+
}) => void): import("react-native").EventSubscription;
|
|
83
|
+
export declare function addMissionRefreshedListener(callback: (event: {
|
|
84
|
+
unitId: string;
|
|
85
|
+
}) => void): import("react-native").EventSubscription;
|
|
86
|
+
declare const sdk: AdchainSDK;
|
|
87
|
+
export default sdk;
|
|
88
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAyBA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EA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,OAAO,CAAC,OAAO,CAAC;IAIjC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAKzB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAGvD;AAID,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,4CAErG;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,4CAE3G;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,4CAE5G;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,4CAExF;AAID,QAAA,MAAM,GAAG,YAAmB,CAAC;AAC7B,eAAe,GAAG,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1selfworld/adchain-sdk-react-native",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "AdChain SDK for React Native with Expo support",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"lib",
|
|
10
|
+
"android",
|
|
11
|
+
"ios",
|
|
12
|
+
"plugin",
|
|
13
|
+
"app.plugin.js",
|
|
14
|
+
"*.podspec",
|
|
15
|
+
"react-native.config.js",
|
|
16
|
+
"!ios/build",
|
|
17
|
+
"!android/build",
|
|
18
|
+
"!android/gradle",
|
|
19
|
+
"!android/gradlew",
|
|
20
|
+
"!android/gradlew.bat",
|
|
21
|
+
"!android/local.properties",
|
|
22
|
+
"!**/__tests__",
|
|
23
|
+
"!**/__fixtures__",
|
|
24
|
+
"!**/__mocks__",
|
|
25
|
+
"!**/.*"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "jest",
|
|
29
|
+
"typecheck": "tsc",
|
|
30
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
31
|
+
"clean": "del-cli lib",
|
|
32
|
+
"prepare": "bob build",
|
|
33
|
+
"release": "release-it --only-version"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"react-native",
|
|
37
|
+
"expo",
|
|
38
|
+
"adchain",
|
|
39
|
+
"ads",
|
|
40
|
+
"offerwall",
|
|
41
|
+
"ios",
|
|
42
|
+
"android"
|
|
43
|
+
],
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/1selfworld-labs/adchain-sdk-react-native.git"
|
|
47
|
+
},
|
|
48
|
+
"author": "1SelfWorld Labs <contacts@1self.world> (https://1self.world)",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/1selfworld-labs/adchain-sdk-react-native/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/1selfworld-labs/adchain-sdk-react-native#readme",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"registry": "https://registry.npmjs.org/",
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"plugin": "app.plugin.js",
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
61
|
+
"@eslint/compat": "^1.3.2",
|
|
62
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
63
|
+
"@eslint/js": "^9.35.0",
|
|
64
|
+
"@evilmartians/lefthook": "^1.12.3",
|
|
65
|
+
"@expo/config-plugins": "^9.0.0",
|
|
66
|
+
"@react-native/babel-preset": "0.81.1",
|
|
67
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
68
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
69
|
+
"@types/jest": "^29.5.14",
|
|
70
|
+
"@types/react": "^19.1.12",
|
|
71
|
+
"commitlint": "^19.8.1",
|
|
72
|
+
"del-cli": "^6.0.0",
|
|
73
|
+
"eslint": "^9.35.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.8",
|
|
75
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
76
|
+
"expo-constants": "^17.0.0",
|
|
77
|
+
"jest": "^29.7.0",
|
|
78
|
+
"prettier": "^3.6.2",
|
|
79
|
+
"react": "18.3.1",
|
|
80
|
+
"react-native": "0.79.2",
|
|
81
|
+
"react-native-builder-bob": "^0.40.13",
|
|
82
|
+
"release-it": "^19.0.4",
|
|
83
|
+
"typescript": "^5.9.2"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"expo": ">=53.0.0",
|
|
87
|
+
"expo-constants": ">=17.0.0",
|
|
88
|
+
"react": ">=18.0.0",
|
|
89
|
+
"react-native": ">=0.79.0"
|
|
90
|
+
},
|
|
91
|
+
"packageManager": "yarn@3.6.1",
|
|
92
|
+
"jest": {
|
|
93
|
+
"preset": "react-native",
|
|
94
|
+
"modulePathIgnorePatterns": [
|
|
95
|
+
"<rootDir>/example/node_modules",
|
|
96
|
+
"<rootDir>/lib/"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"commitlint": {
|
|
100
|
+
"extends": [
|
|
101
|
+
"@commitlint/config-conventional"
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
"release-it": {
|
|
105
|
+
"git": {
|
|
106
|
+
"commitMessage": "chore: release ${version}",
|
|
107
|
+
"tagName": "v${version}"
|
|
108
|
+
},
|
|
109
|
+
"npm": {
|
|
110
|
+
"publish": true
|
|
111
|
+
},
|
|
112
|
+
"github": {
|
|
113
|
+
"release": true
|
|
114
|
+
},
|
|
115
|
+
"plugins": {
|
|
116
|
+
"@release-it/conventional-changelog": {
|
|
117
|
+
"preset": {
|
|
118
|
+
"name": "angular"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"prettier": {
|
|
124
|
+
"quoteProps": "consistent",
|
|
125
|
+
"singleQuote": true,
|
|
126
|
+
"tabWidth": 2,
|
|
127
|
+
"trailingComma": "es5",
|
|
128
|
+
"useTabs": false
|
|
129
|
+
},
|
|
130
|
+
"react-native-builder-bob": {
|
|
131
|
+
"source": "src",
|
|
132
|
+
"output": "lib",
|
|
133
|
+
"targets": [
|
|
134
|
+
[
|
|
135
|
+
"module",
|
|
136
|
+
{
|
|
137
|
+
"esm": true
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
[
|
|
141
|
+
"typescript",
|
|
142
|
+
{
|
|
143
|
+
"project": "tsconfig.build.json"
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"create-react-native-library": {
|
|
149
|
+
"type": "library",
|
|
150
|
+
"languages": "js",
|
|
151
|
+
"version": "0.54.7"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const { withSettingsGradle } = require('@expo/config-plugins');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* v4.1: settings.gradle에 JitPack repository만 추가
|
|
5
|
+
* - AGP 8+ 호환
|
|
6
|
+
* - dependencyResolutionManagement 사용
|
|
7
|
+
* - 의존성은 라이브러리 모듈에서 선언 (중복 방지)
|
|
8
|
+
*/
|
|
9
|
+
function withAdchainAndroid(config) {
|
|
10
|
+
return withSettingsGradle(config, (config) => {
|
|
11
|
+
let settingsGradle = config.modResults.contents;
|
|
12
|
+
|
|
13
|
+
// JitPack repository 추가
|
|
14
|
+
if (!settingsGradle.includes('maven { url "https://jitpack.io" }')) {
|
|
15
|
+
// dependencyResolutionManagement > repositories 블록 찾기
|
|
16
|
+
const drmMatch = settingsGradle.match(
|
|
17
|
+
/(dependencyResolutionManagement\s*\{[\s\S]*?repositories\s*\{)/
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
if (drmMatch) {
|
|
21
|
+
// AGP 8+ 스타일
|
|
22
|
+
settingsGradle = settingsGradle.replace(
|
|
23
|
+
drmMatch[0],
|
|
24
|
+
`${drmMatch[0]}\n maven { url "https://jitpack.io" }`
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
// Fallback: allprojects 스타일 (AGP 7)
|
|
28
|
+
const allprojectsMatch = settingsGradle.match(
|
|
29
|
+
/(allprojects\s*\{\s*repositories\s*\{)/
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (allprojectsMatch) {
|
|
33
|
+
settingsGradle = settingsGradle.replace(
|
|
34
|
+
allprojectsMatch[0],
|
|
35
|
+
`${allprojectsMatch[0]}\n maven { url "https://jitpack.io" }`
|
|
36
|
+
);
|
|
37
|
+
} else {
|
|
38
|
+
// 최후 수단: 파일 끝에 추가
|
|
39
|
+
settingsGradle += `
|
|
40
|
+
// AdChain SDK - JitPack repository
|
|
41
|
+
dependencyResolutionManagement {
|
|
42
|
+
repositories {
|
|
43
|
+
maven { url "https://jitpack.io" }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
config.modResults.contents = settingsGradle;
|
|
52
|
+
return config;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = withAdchainAndroid;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function withAdchainConfig(config, props = {}) {
|
|
2
|
+
// 플랫폼별 설정 지원
|
|
3
|
+
const androidConfig = props.android || {};
|
|
4
|
+
const iosConfig = props.ios || {};
|
|
5
|
+
|
|
6
|
+
// app.json extra에 AdChain 설정 주입
|
|
7
|
+
config.extra = {
|
|
8
|
+
...config.extra,
|
|
9
|
+
// 플랫폼별 credentials
|
|
10
|
+
adchainAndroidAppKey: androidConfig.appKey || props.appKey,
|
|
11
|
+
adchainAndroidAppSecret: androidConfig.appSecret || props.appSecret,
|
|
12
|
+
adchainIosAppKey: iosConfig.appKey || props.appKey,
|
|
13
|
+
adchainIosAppSecret: iosConfig.appSecret || props.appSecret,
|
|
14
|
+
// 공통 설정
|
|
15
|
+
adchainEnvironment: props.environment || 'PRODUCTION',
|
|
16
|
+
adchainTimeout: props.timeout || 30000
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = withAdchainConfig;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const { withPodfile, withInfoPlist } = require('@expo/config-plugins');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* v4.1: Podfile에 Git Pod만 추가
|
|
5
|
+
* - Podspec에는 의존성 선언하지 않음 (Git Pod는 Podspec에서 불가)
|
|
6
|
+
* - CocoaPods Trunk에 없으므로 Git Pod 필요
|
|
7
|
+
* - use_frameworks! 제거 (충돌 방지)
|
|
8
|
+
* - Info.plist에 NSUserTrackingUsageDescription 추가 (App Tracking Transparency 필수)
|
|
9
|
+
*/
|
|
10
|
+
function withAdchainIOS(config) {
|
|
11
|
+
// 1. Info.plist 수정 - NSUserTrackingUsageDescription 추가
|
|
12
|
+
config = withInfoPlist(config, (config) => {
|
|
13
|
+
config.modResults.NSUserTrackingUsageDescription =
|
|
14
|
+
config.modResults.NSUserTrackingUsageDescription ||
|
|
15
|
+
'This app uses tracking to provide personalized ads and measure ad performance.';
|
|
16
|
+
return config;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// 2. Podfile 수정 - AdChainSDK Git Pod 추가
|
|
20
|
+
return withPodfile(config, (config) => {
|
|
21
|
+
let podfile = config.modResults.contents;
|
|
22
|
+
|
|
23
|
+
// AdChainSDK Git Pod 추가
|
|
24
|
+
if (!podfile.includes('AdChainSDK')) {
|
|
25
|
+
// 메인 target 찾기 (첫 번째 target)
|
|
26
|
+
const targetMatch = podfile.match(/target\s+'([^']+)'\s+do/);
|
|
27
|
+
|
|
28
|
+
if (targetMatch) {
|
|
29
|
+
const targetName = targetMatch[1];
|
|
30
|
+
const podDeclaration = `
|
|
31
|
+
# AdChain SDK (Git Pod) - v1.0.42
|
|
32
|
+
# CocoaPods Trunk에 없으므로 Git 방식 사용
|
|
33
|
+
# Swift 5.5 (5.9 optional 파라미터 버그 회피)
|
|
34
|
+
pod 'AdChainSDK', :git => 'https://github.com/1selfworld-labs/adchain-sdk-ios-release.git', :tag => 'v1.0.42'
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
podfile = podfile.replace(
|
|
38
|
+
new RegExp(`(target\\s+'${targetName}'\\s+do)`),
|
|
39
|
+
`$1${podDeclaration}`
|
|
40
|
+
);
|
|
41
|
+
} else {
|
|
42
|
+
// Fallback
|
|
43
|
+
const podDeclaration = `
|
|
44
|
+
# AdChain SDK (Git Pod) - v1.0.42
|
|
45
|
+
pod 'AdChainSDK', :git => 'https://github.com/1selfworld-labs/adchain-sdk-ios-release.git', :tag => 'v1.0.42'
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
podfile = podfile.replace(
|
|
49
|
+
/target\s+'[^']+'\s+do/,
|
|
50
|
+
`$&${podDeclaration}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
config.modResults.contents = podfile;
|
|
56
|
+
return config;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = withAdchainIOS;
|