react-native-s2offerwall 1.0.0
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 +38 -0
- package/android/build.gradle +78 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/snapplay/s2offerwall_rn/S2OfferwallModule.java +224 -0
- package/android/src/main/java/io/snapplay/s2offerwall_rn/S2OfferwallPackage.java +25 -0
- package/ios/S2OfferwallModule.m +205 -0
- package/lib/module/NativeS2Offerwall.js +97 -0
- package/lib/module/NativeS2Offerwall.js.map +1 -0
- package/lib/module/index.js +5 -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/NativeS2Offerwall.d.ts +40 -0
- package/lib/typescript/src/NativeS2Offerwall.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +170 -0
- package/s2offerwall_rn.podspec +24 -0
- package/src/NativeS2Offerwall.ts +124 -0
- package/src/index.tsx +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 devman
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# react-native-s2offerwall
|
|
2
|
+
|
|
3
|
+
React native plugin for S2Offerwall
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install react-native-s2offerwall
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { multiply } from 'react-native-s2offerwall';
|
|
18
|
+
|
|
19
|
+
// ...
|
|
20
|
+
|
|
21
|
+
const result = multiply(3, 7);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
- [Development workflow](CONTRIBUTING.md#development-workflow)
|
|
28
|
+
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
29
|
+
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
38
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['S2offerwall_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
dependencies {
|
|
12
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
13
|
+
// noinspection DifferentKotlinGradleVersion
|
|
14
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
apply plugin: "com.android.library"
|
|
20
|
+
apply plugin: "kotlin-android"
|
|
21
|
+
|
|
22
|
+
apply plugin: "com.facebook.react"
|
|
23
|
+
|
|
24
|
+
def getExtOrIntegerDefault(name) {
|
|
25
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["S2Offerwall_" + name]).toInteger()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
android {
|
|
29
|
+
namespace "io.snapplay.s2offerwall_rn"
|
|
30
|
+
|
|
31
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
32
|
+
|
|
33
|
+
defaultConfig {
|
|
34
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
35
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
buildFeatures {
|
|
39
|
+
buildConfig true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
buildTypes {
|
|
43
|
+
release {
|
|
44
|
+
minifyEnabled false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
lintOptions {
|
|
49
|
+
disable "GradleCompatible"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
compileOptions {
|
|
53
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
54
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
sourceSets {
|
|
58
|
+
main {
|
|
59
|
+
java.srcDirs += [
|
|
60
|
+
"generated/java",
|
|
61
|
+
"generated/jni"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
repositories {
|
|
68
|
+
mavenCentral()
|
|
69
|
+
google()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
73
|
+
|
|
74
|
+
dependencies {
|
|
75
|
+
implementation "com.facebook.react:react-android"
|
|
76
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
77
|
+
implementation("io.snapplay:s2offerwall-aos-sdk:1.0.17")
|
|
78
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
package io.snapplay.s2offerwall_rn;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.Arguments;
|
|
9
|
+
import com.facebook.react.bridge.Promise;
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
13
|
+
import com.facebook.react.bridge.WritableMap;
|
|
14
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
15
|
+
|
|
16
|
+
import s2.adapi.sdk.offerwall.S2Offerwall;
|
|
17
|
+
|
|
18
|
+
public class S2OfferwallModule extends ReactContextBaseJavaModule {
|
|
19
|
+
private static final String TAG = "S2OfferwallModule";
|
|
20
|
+
|
|
21
|
+
public S2OfferwallModule(@NonNull ReactApplicationContext reactContext) {
|
|
22
|
+
super(reactContext);
|
|
23
|
+
//registerOfferwallListener();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@NonNull
|
|
27
|
+
@Override
|
|
28
|
+
public String getName() {
|
|
29
|
+
return "S2OfferwallModule";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 이벤트 전송
|
|
33
|
+
private void sendEvent(String eventName, WritableMap params) {
|
|
34
|
+
if (getReactApplicationContext().hasActiveCatalystInstance()) {
|
|
35
|
+
getReactApplicationContext()
|
|
36
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
37
|
+
.emit(eventName, params);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private void registerOfferwallListener() {
|
|
42
|
+
S2Offerwall.setEventListener(new S2Offerwall.EventListener() {
|
|
43
|
+
@Override
|
|
44
|
+
public void onLoginRequested(String param) {
|
|
45
|
+
WritableMap map = Arguments.createMap();
|
|
46
|
+
map.putString("name", "onLoginRequested");
|
|
47
|
+
map.putString("param", param);
|
|
48
|
+
sendEvent("onLoginRequested", map);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Override
|
|
52
|
+
public void onCloseRequested(String param) {
|
|
53
|
+
// 필요시 구현
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@Override
|
|
57
|
+
public void onPermissionRequested(String permission) {
|
|
58
|
+
// 필요시 구현
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@ReactMethod
|
|
64
|
+
public void initSdk(Promise promise) {
|
|
65
|
+
Activity activity = getCurrentActivity();
|
|
66
|
+
if (activity == null) {
|
|
67
|
+
promise.reject("NO_ACTIVITY", "Activity is not attached");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
registerOfferwallListener();
|
|
72
|
+
|
|
73
|
+
S2Offerwall.initSdk(activity, new S2Offerwall.InitializeListener() {
|
|
74
|
+
@Override
|
|
75
|
+
public void onSuccess() {
|
|
76
|
+
WritableMap map = Arguments.createMap();
|
|
77
|
+
map.putString("name", "onInitCompleted");
|
|
78
|
+
map.putBoolean("flag", true);
|
|
79
|
+
sendEvent("onInitCompleted", map);
|
|
80
|
+
promise.resolve(null);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Override
|
|
84
|
+
public void onFailure() {
|
|
85
|
+
WritableMap map = Arguments.createMap();
|
|
86
|
+
map.putString("name", "onInitCompleted");
|
|
87
|
+
map.putBoolean("flag", false);
|
|
88
|
+
sendEvent("onInitCompleted", map);
|
|
89
|
+
promise.resolve(null);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@ReactMethod
|
|
95
|
+
public void showOfferwall(String placementName, Promise promise) {
|
|
96
|
+
Activity activity = getCurrentActivity();
|
|
97
|
+
if (activity == null) {
|
|
98
|
+
promise.reject("NO_ACTIVITY", "Activity is not attached");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
activity.runOnUiThread(() -> {
|
|
102
|
+
S2Offerwall.startActivity(activity, placementName);
|
|
103
|
+
promise.resolve(null);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactMethod
|
|
108
|
+
public void setAppId(String appId, Promise promise) {
|
|
109
|
+
Activity activity = getCurrentActivity();
|
|
110
|
+
if (activity != null) {
|
|
111
|
+
S2Offerwall.setAppId(activity, appId);
|
|
112
|
+
}
|
|
113
|
+
promise.resolve(null);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@ReactMethod
|
|
117
|
+
public void setAppIdForAndroid(String appId, Promise promise) {
|
|
118
|
+
setAppId(appId, promise);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@ReactMethod
|
|
122
|
+
public void setAppIdForIOS(String appId, Promise promise) {
|
|
123
|
+
// Android에서는 실행 안 함
|
|
124
|
+
promise.resolve(null);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@ReactMethod
|
|
128
|
+
public void setUserName(String userName, Promise promise) {
|
|
129
|
+
Activity activity = getCurrentActivity();
|
|
130
|
+
if (activity != null) {
|
|
131
|
+
S2Offerwall.setUserName(activity, userName);
|
|
132
|
+
}
|
|
133
|
+
promise.resolve(null);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@ReactMethod
|
|
137
|
+
public void getUserName(Promise promise) {
|
|
138
|
+
Activity activity = getCurrentActivity();
|
|
139
|
+
if (activity != null) {
|
|
140
|
+
String userName = S2Offerwall.getUserName(activity);
|
|
141
|
+
promise.resolve(userName);
|
|
142
|
+
} else {
|
|
143
|
+
promise.resolve("");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@ReactMethod
|
|
148
|
+
public void resetUserName(Promise promise) {
|
|
149
|
+
Activity activity = getCurrentActivity();
|
|
150
|
+
if (activity != null) {
|
|
151
|
+
S2Offerwall.resetUserName(activity);
|
|
152
|
+
}
|
|
153
|
+
promise.resolve(null);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@ReactMethod
|
|
157
|
+
public void presentATTPopup(Promise promise) {
|
|
158
|
+
// Android에서는 구현 없을 경우
|
|
159
|
+
promise.resolve(null);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@ReactMethod
|
|
163
|
+
public void setConsentDialogRequired(boolean required, Promise promise) {
|
|
164
|
+
Activity activity = getCurrentActivity();
|
|
165
|
+
if (activity != null) {
|
|
166
|
+
S2Offerwall.setConsentDialogRequired(activity, required);
|
|
167
|
+
}
|
|
168
|
+
promise.resolve(null);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@ReactMethod
|
|
172
|
+
public void setConsentAgreed(boolean agreed, Promise promise) {
|
|
173
|
+
Activity activity = getCurrentActivity();
|
|
174
|
+
if (activity != null) {
|
|
175
|
+
S2Offerwall.setConsentAgreed(activity, agreed);
|
|
176
|
+
}
|
|
177
|
+
promise.resolve(null);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@ReactMethod
|
|
181
|
+
public void requestOfferwallData(String placementName, boolean isEmbeded, Promise promise) {
|
|
182
|
+
Activity activity = getCurrentActivity();
|
|
183
|
+
if (activity == null) {
|
|
184
|
+
promise.reject("NO_ACTIVITY", "Activity is not attached");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
new Thread(() -> {
|
|
189
|
+
String data = S2Offerwall.requestOfferwallData(activity, placementName, isEmbeded);
|
|
190
|
+
promise.resolve(data);
|
|
191
|
+
}).start();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@ReactMethod
|
|
195
|
+
public void openAdItem(double advId, boolean needDetail, String placementFrom, Promise promise) {
|
|
196
|
+
Activity activity = getCurrentActivity();
|
|
197
|
+
if (activity != null) {
|
|
198
|
+
activity.runOnUiThread(() -> {
|
|
199
|
+
S2Offerwall.openAdItem(activity, (long) advId, needDetail, placementFrom);
|
|
200
|
+
});
|
|
201
|
+
promise.resolve(null);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
promise.reject("NO_ACTIVITY", "Activity is not attached");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
@ReactMethod
|
|
209
|
+
public void closeTop(Promise promise) {
|
|
210
|
+
S2Offerwall.closeTop();
|
|
211
|
+
promise.resolve(null);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@ReactMethod
|
|
215
|
+
public void closeAll(Promise promise) {
|
|
216
|
+
S2Offerwall.closeAll();
|
|
217
|
+
promise.resolve(null);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@ReactMethod
|
|
221
|
+
public void getPlatformVersion(Promise promise) {
|
|
222
|
+
promise.resolve("Android " + android.os.Build.VERSION.RELEASE);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package io.snapplay.s2offerwall_rn;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage;
|
|
4
|
+
import com.facebook.react.bridge.NativeModule;
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
7
|
+
|
|
8
|
+
import java.util.ArrayList;
|
|
9
|
+
import java.util.Collections;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
public class S2OfferwallPackage implements ReactPackage {
|
|
13
|
+
|
|
14
|
+
@Override
|
|
15
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
16
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
17
|
+
modules.add(new S2OfferwallModule(reactContext));
|
|
18
|
+
return modules;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Override
|
|
22
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
23
|
+
return Collections.emptyList();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTEventEmitter.h>
|
|
3
|
+
#import <React/RCTLog.h>
|
|
4
|
+
|
|
5
|
+
#import <s2offerwall/s2offerwall-Swift.h>
|
|
6
|
+
|
|
7
|
+
// MARK: - Module Interface & Protocols
|
|
8
|
+
|
|
9
|
+
// S2OfferwallModule 인터페이스 정의 및 RCTBridgeModule, RCTEventEmitter 상속
|
|
10
|
+
@interface S2OfferwallModule : RCTEventEmitter <RCTBridgeModule, S2OfferwallEventListener, S2OfferwallInitializeListener>
|
|
11
|
+
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
// MARK: - Implementation
|
|
15
|
+
|
|
16
|
+
@implementation S2OfferwallModule {
|
|
17
|
+
BOOL hasListeners;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 모듈 이름을 JavaScript에 노출합니다.
|
|
21
|
+
RCT_EXPORT_MODULE();
|
|
22
|
+
|
|
23
|
+
// MARK: - RCTEventEmitter Overrides
|
|
24
|
+
|
|
25
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
26
|
+
return @[@"onInitCompleted", @"onLoginRequested"];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (void)startObserving {
|
|
30
|
+
hasListeners = YES;
|
|
31
|
+
// 이벤트 리스너가 추가될 때 네이티브 리스너를 설정할 수 있습니다.
|
|
32
|
+
[S2Offerwall setEventListener:self];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (void)stopObserving {
|
|
36
|
+
hasListeners = NO;
|
|
37
|
+
// 이벤트 리스너가 모두 제거되면 네이티브 리스너를 해제할 수 있습니다.
|
|
38
|
+
[S2Offerwall setEventListener:nil];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// MARK: - Helper to send events
|
|
42
|
+
|
|
43
|
+
// Swift 코드의 private func sendEvent(_ name: String, body: [String: Any])를 대체
|
|
44
|
+
- (void)sendEvent:(NSString *)name body:(NSDictionary *)body {
|
|
45
|
+
if (hasListeners) {
|
|
46
|
+
[self sendEventWithName:name body:body];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// MARK: - React Methods (RCT_EXPORT_METHOD)
|
|
51
|
+
|
|
52
|
+
// initSdk
|
|
53
|
+
RCT_EXPORT_METHOD(initSdk:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
54
|
+
{
|
|
55
|
+
// Swift 코드의 S2Offerwall.setEventListener(self); 는 startObserving에서 처리됩니다.
|
|
56
|
+
|
|
57
|
+
// Swift 코드: S2Offerwall.initSdk(self)
|
|
58
|
+
// S2OfferwallInitializeListener 구현을 위해 self를 넘깁니다.
|
|
59
|
+
[S2Offerwall initSdk:self];
|
|
60
|
+
resolve(nil);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// showOfferwall
|
|
64
|
+
RCT_EXPORT_METHOD(showOfferwall:(NSString *)placementName
|
|
65
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
66
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
67
|
+
{
|
|
68
|
+
// Swift 코드: guard let vc = ...
|
|
69
|
+
UIViewController *rootVC = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
70
|
+
|
|
71
|
+
if (!rootVC) {
|
|
72
|
+
reject(@"NO_VIEWCONTROLLER", @"No root view controller", nil);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
77
|
+
// Swift 코드: S2Offerwall.presentOfferwall(vc, placementName: placementName)
|
|
78
|
+
[S2Offerwall presentOfferwall:rootVC placementName:placementName];
|
|
79
|
+
resolve(nil);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// setAppId
|
|
85
|
+
RCT_EXPORT_METHOD(setAppId:(NSString *)appId
|
|
86
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
87
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
88
|
+
{
|
|
89
|
+
// Swift 코드: S2Offerwall.setAppId(appId)
|
|
90
|
+
[S2Offerwall setAppId:appId];
|
|
91
|
+
resolve(nil);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// setUserName
|
|
95
|
+
RCT_EXPORT_METHOD(setUserName:(NSString *)username
|
|
96
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
97
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
98
|
+
{
|
|
99
|
+
// Swift 코드: S2Offerwall.setUserName(username)
|
|
100
|
+
[S2Offerwall setUserName:username];
|
|
101
|
+
resolve(nil);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// getUserName
|
|
105
|
+
RCT_EXPORT_METHOD(getUserName:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
106
|
+
{
|
|
107
|
+
// Swift 코드: let username = S2Offerwall.getUserName() ?? ""
|
|
108
|
+
NSString *username = [S2Offerwall getUserName];
|
|
109
|
+
resolve(username ?: @""); // nil coalescing
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// resetUserName
|
|
113
|
+
RCT_EXPORT_METHOD(resetUserName:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
114
|
+
{
|
|
115
|
+
// Swift 코드: S2Offerwall.resetUserName()
|
|
116
|
+
[S2Offerwall resetUserName];
|
|
117
|
+
resolve(nil);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// requestOfferwallData
|
|
121
|
+
RCT_EXPORT_METHOD(requestOfferwallData:(NSString *)placementName
|
|
122
|
+
isEmbeded:(BOOL)isEmbeded
|
|
123
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
124
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
125
|
+
{
|
|
126
|
+
// Swift 코드: S2Offerwall.requestOfferwallData(...) { data in resolve(data) }
|
|
127
|
+
[S2Offerwall requestOfferwallDataWithPlacementName:placementName isEmbeded:isEmbeded completion:^(NSString * dataString) {
|
|
128
|
+
// 받은 String 데이터를 Promise의 resolve로 전달합니다.
|
|
129
|
+
resolve(dataString);
|
|
130
|
+
}];
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// openAdItem
|
|
135
|
+
RCT_EXPORT_METHOD(openAdItem:(NSInteger)advId
|
|
136
|
+
needDetail:(BOOL)needDetail
|
|
137
|
+
placementFrom:(NSString *)placementFrom
|
|
138
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
139
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
140
|
+
{
|
|
141
|
+
// Swift 코드: guard let vc = ...
|
|
142
|
+
UIViewController *rootVC = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
143
|
+
|
|
144
|
+
if (!rootVC) {
|
|
145
|
+
reject(@"NO_VIEWCONTROLLER", @"No root view controller", nil);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
150
|
+
// Swift 코드: S2Offerwall.openAdItem(...)
|
|
151
|
+
[S2Offerwall openAdItem:rootVC advId:advId needDetail:needDetail placementFrom:placementFrom];
|
|
152
|
+
resolve(nil);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// closeTop
|
|
157
|
+
RCT_EXPORT_METHOD(closeTop:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
158
|
+
{
|
|
159
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
160
|
+
// Swift 코드: S2Offerwall.closeTop() { resolve(nil) }
|
|
161
|
+
[S2Offerwall closeTopWithCompletion:^(void) {
|
|
162
|
+
resolve(nil);
|
|
163
|
+
}];
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// closeAll
|
|
168
|
+
RCT_EXPORT_METHOD(closeAll:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
169
|
+
{
|
|
170
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
171
|
+
// Swift 코드: S2Offerwall.closeAll() { resolve(nil) }
|
|
172
|
+
[S2Offerwall closeAllWithCompletion:^{
|
|
173
|
+
resolve(nil);
|
|
174
|
+
}];
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// getPlatformVersion
|
|
179
|
+
RCT_EXPORT_METHOD(getPlatformVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
180
|
+
{
|
|
181
|
+
// Swift 코드: "iOS " + UIDevice.current.systemVersion
|
|
182
|
+
NSString *platformVersion = [NSString stringWithFormat:@"iOS %@", [[UIDevice currentDevice] systemVersion]];
|
|
183
|
+
resolve(platformVersion);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// MARK: - S2OfferwallEventListener
|
|
187
|
+
|
|
188
|
+
- (void)onLoginRequested:(NSString * _Nullable)param {
|
|
189
|
+
// Swift 코드: sendEvent("onLoginRequested", body: ...)
|
|
190
|
+
[self sendEvent:@"onLoginRequested" body:@{@"name": @"onLoginRequested", @"param": param ?: @""}];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// MARK: - S2OfferwallInitializeListener
|
|
194
|
+
|
|
195
|
+
- (void)onSuccess {
|
|
196
|
+
// Swift 코드: sendEvent("onInitCompleted", body: ["flag": true])
|
|
197
|
+
[self sendEvent:@"onInitCompleted" body:@{@"name": @"onInitCompleted", @"flag": @YES}];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
- (void)onFailure {
|
|
201
|
+
// Swift 코드: sendEvent("onInitCompleted", body: ["flag": false])
|
|
202
|
+
[self sendEvent:@"onInitCompleted" body:@{@"name": @"onInitCompleted", @"flag": @NO}];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
4
|
+
// ✅ Native 모듈 이름은 S2OfferwallModule 입니다.
|
|
5
|
+
const {
|
|
6
|
+
S2OfferwallModule
|
|
7
|
+
} = NativeModules;
|
|
8
|
+
|
|
9
|
+
// 이벤트 타입 정의
|
|
10
|
+
|
|
11
|
+
// 핵심: S2OfferwallModule을 래핑하고 모든 메서드와 리스너를 포함하는 단일 객체입니다.
|
|
12
|
+
// 이 객체를 'S2Offerwall'이라는 이름으로 명시적으로 내보냅니다.
|
|
13
|
+
const eventEmitter = new NativeEventEmitter(S2OfferwallModule);
|
|
14
|
+
let subscriptions = [];
|
|
15
|
+
export const S2Offerwall = {
|
|
16
|
+
// --- 이벤트 구독 메서드 ---
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @description 로그인 요청 이벤트를 구독합니다.
|
|
20
|
+
*/
|
|
21
|
+
onLoginRequested(callback) {
|
|
22
|
+
const sub = eventEmitter.addListener('onLoginRequested', callback);
|
|
23
|
+
subscriptions.push(sub);
|
|
24
|
+
return sub;
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* @description SDK 초기화 완료 이벤트를 구독합니다.
|
|
28
|
+
*/
|
|
29
|
+
onInitCompleted(callback) {
|
|
30
|
+
const sub = eventEmitter.addListener('onInitCompleted', callback);
|
|
31
|
+
subscriptions.push(sub);
|
|
32
|
+
return sub;
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* @description 등록된 모든 이벤트 리스너를 제거합니다.
|
|
36
|
+
*/
|
|
37
|
+
removeAllListeners() {
|
|
38
|
+
subscriptions.forEach(sub => sub.remove());
|
|
39
|
+
subscriptions = [];
|
|
40
|
+
},
|
|
41
|
+
// --- Native Module 메서드 ---
|
|
42
|
+
|
|
43
|
+
// 모든 메서드는 NativeModules 객체에서 직접 호출되도록 래핑됩니다.
|
|
44
|
+
|
|
45
|
+
initSdk() {
|
|
46
|
+
return S2OfferwallModule.initSdk();
|
|
47
|
+
},
|
|
48
|
+
showOfferwall(placementName) {
|
|
49
|
+
return S2OfferwallModule.showOfferwall(placementName);
|
|
50
|
+
},
|
|
51
|
+
setAppId(appId) {
|
|
52
|
+
return S2OfferwallModule.setAppId(appId);
|
|
53
|
+
},
|
|
54
|
+
setAppIdForAndroid(appId) {
|
|
55
|
+
if (Platform.OS === 'android') {
|
|
56
|
+
return S2OfferwallModule.setAppIdForAndroid(appId);
|
|
57
|
+
}
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
},
|
|
60
|
+
setAppIdForIOS(appId) {
|
|
61
|
+
if (Platform.OS === 'ios') {
|
|
62
|
+
return S2OfferwallModule.setAppId(appId);
|
|
63
|
+
}
|
|
64
|
+
return Promise.resolve();
|
|
65
|
+
},
|
|
66
|
+
setUserName(userName) {
|
|
67
|
+
return S2OfferwallModule.setUserName(userName);
|
|
68
|
+
},
|
|
69
|
+
getUserName() {
|
|
70
|
+
return S2OfferwallModule.getUserName();
|
|
71
|
+
},
|
|
72
|
+
resetUserName() {
|
|
73
|
+
return S2OfferwallModule.resetUserName();
|
|
74
|
+
},
|
|
75
|
+
presentATTPopup() {
|
|
76
|
+
return S2OfferwallModule.presentATTPopup();
|
|
77
|
+
},
|
|
78
|
+
setConsentDialogRequired(required) {
|
|
79
|
+
return S2OfferwallModule.setConsentDialogRequired(required);
|
|
80
|
+
},
|
|
81
|
+
requestOfferwallData(placementName, isEmbeded) {
|
|
82
|
+
return S2OfferwallModule.requestOfferwallData(placementName, isEmbeded);
|
|
83
|
+
},
|
|
84
|
+
openAdItem(advId, needDetail, placementFrom) {
|
|
85
|
+
return S2OfferwallModule.openAdItem(advId, needDetail, placementFrom);
|
|
86
|
+
},
|
|
87
|
+
closeTop() {
|
|
88
|
+
return S2OfferwallModule.closeTop();
|
|
89
|
+
},
|
|
90
|
+
closeAll() {
|
|
91
|
+
return S2OfferwallModule.closeAll();
|
|
92
|
+
},
|
|
93
|
+
getPlatformVersion() {
|
|
94
|
+
return S2OfferwallModule.getPlatformVersion();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=NativeS2Offerwall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","S2OfferwallModule","eventEmitter","subscriptions","S2Offerwall","onLoginRequested","callback","sub","addListener","push","onInitCompleted","removeAllListeners","forEach","remove","initSdk","showOfferwall","placementName","setAppId","appId","setAppIdForAndroid","OS","Promise","resolve","setAppIdForIOS","setUserName","userName","getUserName","resetUserName","presentATTPopup","setConsentDialogRequired","required","requestOfferwallData","isEmbeded","openAdItem","advId","needDetail","placementFrom","closeTop","closeAll","getPlatformVersion"],"sourceRoot":"../../src","sources":["NativeS2Offerwall.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["S2Offerwall"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA,SAASA,WAAW,QAAQ,wBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { EventSubscription } from 'react-native';
|
|
2
|
+
export type S2OfferwallEvent = {
|
|
3
|
+
name: 'onInitCompleted';
|
|
4
|
+
flag: boolean;
|
|
5
|
+
} | {
|
|
6
|
+
name: 'onLoginRequested';
|
|
7
|
+
param: string;
|
|
8
|
+
};
|
|
9
|
+
type EventCallback = (data: S2OfferwallEvent) => void;
|
|
10
|
+
export declare const S2Offerwall: {
|
|
11
|
+
/**
|
|
12
|
+
* @description 로그인 요청 이벤트를 구독합니다.
|
|
13
|
+
*/
|
|
14
|
+
onLoginRequested(callback: EventCallback): EventSubscription;
|
|
15
|
+
/**
|
|
16
|
+
* @description SDK 초기화 완료 이벤트를 구독합니다.
|
|
17
|
+
*/
|
|
18
|
+
onInitCompleted(callback: EventCallback): EventSubscription;
|
|
19
|
+
/**
|
|
20
|
+
* @description 등록된 모든 이벤트 리스너를 제거합니다.
|
|
21
|
+
*/
|
|
22
|
+
removeAllListeners(): void;
|
|
23
|
+
initSdk(): Promise<void>;
|
|
24
|
+
showOfferwall(placementName: string): Promise<void>;
|
|
25
|
+
setAppId(appId: string): Promise<void>;
|
|
26
|
+
setAppIdForAndroid(appId: string): Promise<void>;
|
|
27
|
+
setAppIdForIOS(appId: string): Promise<void>;
|
|
28
|
+
setUserName(userName: string): Promise<void>;
|
|
29
|
+
getUserName(): Promise<string>;
|
|
30
|
+
resetUserName(): Promise<void>;
|
|
31
|
+
presentATTPopup(): Promise<void>;
|
|
32
|
+
setConsentDialogRequired(required: boolean): Promise<void>;
|
|
33
|
+
requestOfferwallData(placementName: string, isEmbeded: boolean): Promise<string>;
|
|
34
|
+
openAdItem(advId: number, needDetail: boolean, placementFrom: string): Promise<void>;
|
|
35
|
+
closeTop(): Promise<void>;
|
|
36
|
+
closeAll(): Promise<void>;
|
|
37
|
+
getPlatformVersion(): Promise<string>;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=NativeS2Offerwall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeS2Offerwall.d.ts","sourceRoot":"","sources":["../../../src/NativeS2Offerwall.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMtD,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAOtD,eAAO,MAAM,WAAW;IAGtB;;OAEG;+BACwB,aAAa,GAAG,iBAAiB;IAM5D;;OAEG;8BACuB,aAAa,GAAG,iBAAiB;IAM3D;;OAEG;;eAUQ,OAAO,CAAC,IAAI,CAAC;iCAIK,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;oBAInC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;8BAIZ,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;0BAO1B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;0BAOtB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;mBAI7B,OAAO,CAAC,MAAM,CAAC;qBAIb,OAAO,CAAC,IAAI,CAAC;uBAIX,OAAO,CAAC,IAAI,CAAC;uCAIG,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;wCAKzC,MAAM,aACV,OAAO,GACjB,OAAO,CAAC,MAAM,CAAC;sBAKT,MAAM,cACD,OAAO,iBACJ,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;gBAIJ,OAAO,CAAC,IAAI,CAAC;gBAIb,OAAO,CAAC,IAAI,CAAC;0BAIH,OAAO,CAAC,MAAM,CAAC;CAGtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-s2offerwall",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React native plugin for S2Offerwall",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace react-native-s2offerwall-example",
|
|
36
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
37
|
+
"prepare": "bob build",
|
|
38
|
+
"typecheck": "tsc",
|
|
39
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
40
|
+
"release": "release-it --only-version",
|
|
41
|
+
"test": "jest"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"react-native",
|
|
45
|
+
"ios",
|
|
46
|
+
"android"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/snapplay-io/rn_offerwall_plugin.git"
|
|
51
|
+
},
|
|
52
|
+
"author": "devman <devman@snapplay.io> (https://github.com/snapplay-io)",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/snapplay-io/rn_offerwall_plugin/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/snapplay-io/rn_offerwall_plugin#readme",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
63
|
+
"@eslint/compat": "^1.3.2",
|
|
64
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
65
|
+
"@eslint/js": "^9.35.0",
|
|
66
|
+
"@react-native-community/cli": "20.0.1",
|
|
67
|
+
"@react-native/babel-preset": "0.81.1",
|
|
68
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
69
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
70
|
+
"@types/jest": "^29.5.14",
|
|
71
|
+
"@types/react": "^19.1.0",
|
|
72
|
+
"commitlint": "^19.8.1",
|
|
73
|
+
"del-cli": "^6.0.0",
|
|
74
|
+
"eslint": "^9.35.0",
|
|
75
|
+
"eslint-config-prettier": "^10.1.8",
|
|
76
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
77
|
+
"jest": "^29.7.0",
|
|
78
|
+
"lefthook": "^2.0.3",
|
|
79
|
+
"prettier": "^3.0.0",
|
|
80
|
+
"react": "19.1.0",
|
|
81
|
+
"react-native": "0.81.1",
|
|
82
|
+
"react-native-builder-bob": "^0.40.15",
|
|
83
|
+
"release-it": "^19.0.4",
|
|
84
|
+
"turbo": "^2.5.6",
|
|
85
|
+
"typescript": "^5.9.2"
|
|
86
|
+
},
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"react": "*",
|
|
89
|
+
"react-native": "*"
|
|
90
|
+
},
|
|
91
|
+
"workspaces": [
|
|
92
|
+
"example"
|
|
93
|
+
],
|
|
94
|
+
"packageManager": "yarn@4.11.0",
|
|
95
|
+
"react-native-builder-bob": {
|
|
96
|
+
"source": "src",
|
|
97
|
+
"output": "lib",
|
|
98
|
+
"targets": [
|
|
99
|
+
[
|
|
100
|
+
"module",
|
|
101
|
+
{
|
|
102
|
+
"esm": true
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
"typescript",
|
|
107
|
+
{
|
|
108
|
+
"project": "tsconfig.build.json"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"codegenConfig": {
|
|
114
|
+
"name": "S2offerwallSpec",
|
|
115
|
+
"type": "modules",
|
|
116
|
+
"jsSrcsDir": "src",
|
|
117
|
+
"android": {
|
|
118
|
+
"javaPackageName": "io.snapplay.s2offerwall_rn"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"prettier": {
|
|
122
|
+
"quoteProps": "consistent",
|
|
123
|
+
"singleQuote": true,
|
|
124
|
+
"tabWidth": 2,
|
|
125
|
+
"trailingComma": "es5",
|
|
126
|
+
"useTabs": false
|
|
127
|
+
},
|
|
128
|
+
"commitlint": {
|
|
129
|
+
"extends": [
|
|
130
|
+
"@commitlint/config-conventional"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"release-it": {
|
|
134
|
+
"git": {
|
|
135
|
+
"commitMessage": "chore: release ${version}",
|
|
136
|
+
"tagName": "v${version}"
|
|
137
|
+
},
|
|
138
|
+
"npm": {
|
|
139
|
+
"publish": true
|
|
140
|
+
},
|
|
141
|
+
"github": {
|
|
142
|
+
"release": true
|
|
143
|
+
},
|
|
144
|
+
"plugins": {
|
|
145
|
+
"@release-it/conventional-changelog": {
|
|
146
|
+
"preset": {
|
|
147
|
+
"name": "angular"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"jest": {
|
|
153
|
+
"preset": "react-native",
|
|
154
|
+
"modulePathIgnorePatterns": [
|
|
155
|
+
"<rootDir>/example/node_modules",
|
|
156
|
+
"<rootDir>/lib/"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"create-react-native-library": {
|
|
160
|
+
"languages": "kotlin-objc",
|
|
161
|
+
"type": "turbo-module",
|
|
162
|
+
"tools": [
|
|
163
|
+
"eslint",
|
|
164
|
+
"lefthook",
|
|
165
|
+
"release-it",
|
|
166
|
+
"jest"
|
|
167
|
+
],
|
|
168
|
+
"version": "0.55.0"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 = "s2offerwall_rn"
|
|
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.platform = :ios, '16.0'
|
|
14
|
+
s.ios.deployment_target = '16.0'
|
|
15
|
+
s.source = { :git => "https://github.com/snapplay-io/rn_offerwall_plugin.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
18
|
+
s.private_header_files = "ios/**/*.h"
|
|
19
|
+
|
|
20
|
+
s.dependency 's2offerwall', '~> 1.0.17'
|
|
21
|
+
s.dependency 'React-Core'
|
|
22
|
+
|
|
23
|
+
install_modules_dependencies(s)
|
|
24
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
|
+
import type { EventSubscription } from 'react-native';
|
|
3
|
+
|
|
4
|
+
// ✅ Native 모듈 이름은 S2OfferwallModule 입니다.
|
|
5
|
+
const { S2OfferwallModule } = NativeModules;
|
|
6
|
+
|
|
7
|
+
// 이벤트 타입 정의
|
|
8
|
+
export type S2OfferwallEvent =
|
|
9
|
+
| { name: 'onInitCompleted'; flag: boolean }
|
|
10
|
+
| { name: 'onLoginRequested'; param: string };
|
|
11
|
+
|
|
12
|
+
type EventCallback = (data: S2OfferwallEvent) => void;
|
|
13
|
+
|
|
14
|
+
// 핵심: S2OfferwallModule을 래핑하고 모든 메서드와 리스너를 포함하는 단일 객체입니다.
|
|
15
|
+
// 이 객체를 'S2Offerwall'이라는 이름으로 명시적으로 내보냅니다.
|
|
16
|
+
const eventEmitter = new NativeEventEmitter(S2OfferwallModule);
|
|
17
|
+
let subscriptions: EventSubscription[] = [];
|
|
18
|
+
|
|
19
|
+
export const S2Offerwall = {
|
|
20
|
+
// --- 이벤트 구독 메서드 ---
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @description 로그인 요청 이벤트를 구독합니다.
|
|
24
|
+
*/
|
|
25
|
+
onLoginRequested(callback: EventCallback): EventSubscription {
|
|
26
|
+
const sub = eventEmitter.addListener('onLoginRequested', callback as any);
|
|
27
|
+
subscriptions.push(sub);
|
|
28
|
+
return sub;
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @description SDK 초기화 완료 이벤트를 구독합니다.
|
|
33
|
+
*/
|
|
34
|
+
onInitCompleted(callback: EventCallback): EventSubscription {
|
|
35
|
+
const sub = eventEmitter.addListener('onInitCompleted', callback as any);
|
|
36
|
+
subscriptions.push(sub);
|
|
37
|
+
return sub;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description 등록된 모든 이벤트 리스너를 제거합니다.
|
|
42
|
+
*/
|
|
43
|
+
removeAllListeners() {
|
|
44
|
+
subscriptions.forEach((sub) => sub.remove());
|
|
45
|
+
subscriptions = [];
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// --- Native Module 메서드 ---
|
|
49
|
+
|
|
50
|
+
// 모든 메서드는 NativeModules 객체에서 직접 호출되도록 래핑됩니다.
|
|
51
|
+
|
|
52
|
+
initSdk(): Promise<void> {
|
|
53
|
+
return S2OfferwallModule.initSdk();
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
showOfferwall(placementName: string): Promise<void> {
|
|
57
|
+
return S2OfferwallModule.showOfferwall(placementName);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
setAppId(appId: string): Promise<void> {
|
|
61
|
+
return S2OfferwallModule.setAppId(appId);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
setAppIdForAndroid(appId: string): Promise<void> {
|
|
65
|
+
if (Platform.OS === 'android') {
|
|
66
|
+
return S2OfferwallModule.setAppIdForAndroid(appId);
|
|
67
|
+
}
|
|
68
|
+
return Promise.resolve();
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
setAppIdForIOS(appId: string): Promise<void> {
|
|
72
|
+
if (Platform.OS === 'ios') {
|
|
73
|
+
return S2OfferwallModule.setAppId(appId);
|
|
74
|
+
}
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
setUserName(userName: string): Promise<void> {
|
|
79
|
+
return S2OfferwallModule.setUserName(userName);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
getUserName(): Promise<string> {
|
|
83
|
+
return S2OfferwallModule.getUserName();
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
resetUserName(): Promise<void> {
|
|
87
|
+
return S2OfferwallModule.resetUserName();
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
presentATTPopup(): Promise<void> {
|
|
91
|
+
return S2OfferwallModule.presentATTPopup();
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
setConsentDialogRequired(required: boolean): Promise<void> {
|
|
95
|
+
return S2OfferwallModule.setConsentDialogRequired(required);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
requestOfferwallData(
|
|
99
|
+
placementName: string,
|
|
100
|
+
isEmbeded: boolean
|
|
101
|
+
): Promise<string> {
|
|
102
|
+
return S2OfferwallModule.requestOfferwallData(placementName, isEmbeded);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
openAdItem(
|
|
106
|
+
advId: number,
|
|
107
|
+
needDetail: boolean,
|
|
108
|
+
placementFrom: string
|
|
109
|
+
): Promise<void> {
|
|
110
|
+
return S2OfferwallModule.openAdItem(advId, needDetail, placementFrom);
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
closeTop(): Promise<void> {
|
|
114
|
+
return S2OfferwallModule.closeTop();
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
closeAll(): Promise<void> {
|
|
118
|
+
return S2OfferwallModule.closeAll();
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
getPlatformVersion(): Promise<string> {
|
|
122
|
+
return S2OfferwallModule.getPlatformVersion();
|
|
123
|
+
},
|
|
124
|
+
};
|
package/src/index.tsx
ADDED