Skip to content

Commit 9502d47

Browse files
committed
fix(user): export android method with @ReactMethod. old arch supporting is so toooooooooooooooooough
1 parent ae9db1a commit 9502d47

File tree

3 files changed

+40
-26
lines changed

3 files changed

+40
-26
lines changed

packages/share/src/index.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
// import { NativeModules, Platform } from 'react-native';
2-
//
3-
// const LINKING_ERROR =
4-
// `The package '@react-native-kakao/share' doesn't seem to be linked. Make sure: \n\n` +
5-
// Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6-
// '- You rebuilt the app after installing the package\n' +
7-
// '- You are not using Expo Go\n';
8-
//
9-
// // @ts-expect-error
10-
// const isTurboModuleEnabled = global.__turboModuleProxy != null;
11-
//
12-
// const Module = isTurboModuleEnabled
13-
// ? require('./spec/NativeKakaoShare').default
14-
// : NativeModules.KakaoShare;
15-
//
16-
// const Native = Module
17-
// ? Module
18-
// : new Proxy(
19-
// {},
20-
// {
21-
// get() {
22-
// throw new Error(LINKING_ERROR);
23-
// },
24-
// }
25-
// );
1+
import { NativeModules, Platform } from 'react-native';
2+
3+
const LINKING_ERROR =
4+
"The package '@react-native-kakao/share' doesn't seem to be linked. Make sure: \n\n" +
5+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6+
'- You rebuilt the app after installing the package\n' +
7+
'- You are not using Expo Go\n';
8+
9+
// @ts-expect-error
10+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
11+
12+
const Module = isTurboModuleEnabled
13+
? require('./spec/NativeKakaoShare').default
14+
: NativeModules.RNCKakaoShare;
15+
16+
const Native = Module
17+
? Module
18+
: new Proxy(
19+
{},
20+
{
21+
get() {
22+
throw new Error(LINKING_ERROR);
23+
},
24+
},
25+
);
26+
27+
export function noob() {
28+
console.log(Native);
29+
}

packages/user/android/src/main/java/net/mjstudio/rnkakao/user/RNCKakaoUserModule.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package net.mjstudio.rnkakao.user
22

33
import com.facebook.react.bridge.Promise
44
import com.facebook.react.bridge.ReactApplicationContext
5+
import com.facebook.react.bridge.ReactMethod
56
import com.facebook.react.bridge.ReadableArray
67
import com.kakao.sdk.auth.AuthApiClient
78
import com.kakao.sdk.auth.model.OAuthToken
@@ -27,6 +28,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
2728
return NAME
2829
}
2930

31+
@ReactMethod
3032
override fun login(
3133
serviceTerms: ReadableArray?,
3234
prompts: ReadableArray?,
@@ -90,10 +92,12 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
9092
}
9193
}
9294

95+
@ReactMethod
9396
override fun isKakaoTalkLoginAvailable(promise: Promise) {
9497
promise.resolve(UserApiClient.instance.isKakaoTalkLoginAvailable(reactApplicationContext))
9598
}
9699

100+
@ReactMethod
97101
override fun logout(promise: Promise) {
98102
UserApiClient.instance.logout {
99103
if (it != null) {
@@ -104,6 +108,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
104108
}
105109
}
106110

111+
@ReactMethod
107112
override fun unlink(promise: Promise) {
108113
UserApiClient.instance.unlink {
109114
if (it != null) {
@@ -114,6 +119,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
114119
}
115120
}
116121

122+
@ReactMethod
117123
override fun isLogined(promise: Promise) {
118124
if (AuthApiClient.instance.hasToken()) {
119125
UserApiClient.instance.accessTokenInfo { _, error ->
@@ -132,6 +138,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
132138
}
133139
}
134140

141+
@ReactMethod
135142
override fun scopes(scopes: ReadableArray?, promise: Promise) {
136143
UserApiClient.instance.scopes { scopeInfo, error ->
137144
if (error != null) {
@@ -156,6 +163,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
156163
}
157164
}
158165

166+
@ReactMethod
159167
override fun revokeScopes(scopes: ReadableArray, promise: Promise) {
160168
UserApiClient.instance.revokeScopes(
161169
scopes = scopes.filterIsInstance<String>() ?: listOf()
@@ -170,6 +178,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
170178
}
171179
}
172180

181+
@ReactMethod
173182
override fun serviceTerms(promise: Promise) {
174183
UserApiClient.instance.serviceTerms { serviceTerms, error ->
175184
if (error != null) {
@@ -191,6 +200,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
191200
}
192201
}
193202

203+
@ReactMethod
194204
override fun shippingAddresses(promise: Promise) {
195205
UserApiClient.instance.shippingAddresses { addrs, error ->
196206
if (error != null) {
@@ -224,6 +234,7 @@ class RNCKakaoUserModule internal constructor(context: ReactApplicationContext)
224234
}
225235
}
226236

237+
@ReactMethod
227238
override fun me(promise: Promise) {
228239
UserApiClient.instance.me { user, error ->
229240
if (error != null) {

packages/user/src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const isTurboModuleEnabled = global.__turboModuleProxy != null;
1414
const Module = isTurboModuleEnabled
1515
? require('./spec/NativeKakaoUser').default
1616
: NativeModules.RNCKakaoUser;
17-
console.log(NativeModules.RNCKakaoUser);
1817

1918
const Native: Spec = Module
2019
? Module

0 commit comments

Comments
 (0)