@chuseok22/capacitor-kakao-login 0.1.5 → 0.1.7
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const APP_VERSION = '0.1.
|
|
1
|
+
export const APP_VERSION = '0.1.7';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -4,11 +4,6 @@ import KakaoSDKCommon
|
|
|
4
4
|
import KakaoSDKAuth
|
|
5
5
|
import KakaoSDKUser
|
|
6
6
|
|
|
7
|
-
/// Capacitor 플러그인 — 카카오 소셜 로그인
|
|
8
|
-
///
|
|
9
|
-
/// capacitor.config.ts에 appKey를 설정하면 load() 시점에 KakaoSDK를 자동 초기화하고,
|
|
10
|
-
/// ApplicationDelegateProxy에 등록해 URL 처리도 자동으로 수행한다.
|
|
11
|
-
/// AppDelegate를 수정할 필요가 없다.
|
|
12
7
|
@objc(KakaoLoginPlugin)
|
|
13
8
|
public class KakaoLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
14
9
|
|
|
@@ -18,44 +13,45 @@ public class KakaoLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
18
13
|
CAPPluginMethod(name: "login", returnType: CAPPluginReturnPromise)
|
|
19
14
|
]
|
|
20
15
|
|
|
21
|
-
/// 플러그인 로드 시 KakaoSDK를 자동 초기화한다.
|
|
22
|
-
/// capacitor.config.ts의 plugins.KakaoLogin.appKey 값을 읽는다.
|
|
23
16
|
public override func load() {
|
|
24
17
|
guard let appKey = getConfigValue("appKey") as? String, !appKey.isEmpty else {
|
|
25
18
|
print("[KakaoLoginPlugin] ⚠️ appKey가 capacitor.config.ts에 설정되지 않았습니다.")
|
|
26
19
|
print("[KakaoLoginPlugin] plugins: { KakaoLogin: { appKey: 'YOUR_NATIVE_APP_KEY' } }")
|
|
27
20
|
return
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
KakaoSDK.initSDK(appKey: appKey)
|
|
23
|
+
// Capacitor 8: CAPPlugin에 handleOpenUrl 오버라이드 불가 — NotificationCenter로 URL 수신
|
|
24
|
+
NotificationCenter.default.addObserver(
|
|
25
|
+
self,
|
|
26
|
+
selector: #selector(handleOpenURL(_:)),
|
|
27
|
+
name: .capacitorOpenURL,
|
|
28
|
+
object: nil
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ApplicationDelegateProxy.shared.add(self)
|
|
32
|
+
deinit {
|
|
33
|
+
NotificationCenter.default.removeObserver(self)
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@objc
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
// Capacitor 8 URL 라우팅: AppDelegate → ApplicationDelegateProxy → capacitorOpenURL 알림
|
|
37
|
+
// notification.object = ["url": URL, "options": [UIApplication.OpenURLOptionsKey: Any]]
|
|
38
|
+
@objc private func handleOpenURL(_ notification: Notification) {
|
|
39
|
+
guard let object = notification.object as? [String: Any],
|
|
40
|
+
let url = object["url"] as? URL else { return }
|
|
41
|
+
guard AuthApi.isKakaoTalkLoginUrl(url) else { return }
|
|
42
|
+
// capacitorOpenURL은 메인 스레드에서 발송 — MainActor.assumeIsolated 안전
|
|
43
|
+
MainActor.assumeIsolated {
|
|
44
|
+
_ = AuthController.handleOpenUrl(url: url)
|
|
46
45
|
}
|
|
47
|
-
return false
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
@objc func login(_ call: CAPPluginCall) {
|
|
51
49
|
DispatchQueue.main.async {
|
|
52
50
|
if UserApi.isKakaoTalkLoginAvailable() {
|
|
53
|
-
// 카카오톡 앱 로그인
|
|
54
51
|
UserApi.shared.loginWithKakaoTalk { [weak self] oauthToken, error in
|
|
55
52
|
self?.handleLoginResult(call: call, oauthToken: oauthToken, error: error)
|
|
56
53
|
}
|
|
57
54
|
} else {
|
|
58
|
-
// 카카오 계정 웹뷰 로그인 (카카오톡 미설치 환경)
|
|
59
55
|
UserApi.shared.loginWithKakaoAccount { [weak self] oauthToken, error in
|
|
60
56
|
self?.handleLoginResult(call: call, oauthToken: oauthToken, error: error)
|
|
61
57
|
}
|
|
@@ -77,12 +73,10 @@ public class KakaoLoginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
77
73
|
call.reject("카카오 사용자 정보 조회 실패", nil, error)
|
|
78
74
|
return
|
|
79
75
|
}
|
|
80
|
-
|
|
81
76
|
guard let userId = user?.id else {
|
|
82
77
|
call.reject("카카오 사용자 ID를 가져올 수 없습니다")
|
|
83
78
|
return
|
|
84
79
|
}
|
|
85
|
-
|
|
86
80
|
call.resolve(["socialId": String(userId)])
|
|
87
81
|
}
|
|
88
82
|
}
|
package/package.json
CHANGED