@chuseok22/capacitor-kakao-login 0.1.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.
@@ -0,0 +1,18 @@
1
+ require 'json'
2
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
3
+
4
+ Pod::Spec.new do |s|
5
+ s.name = 'CapacitorKakaoLogin'
6
+ s.version = package['version']
7
+ s.summary = 'Capacitor plugin for Kakao social login (iOS & Android)'
8
+ s.homepage = 'https://github.com/chuseok22/capacitor-kakao-login'
9
+ s.license = 'MIT'
10
+ s.author = { 'Baek Jihoon' => 'chuseok22@gmail.com' }
11
+ s.source = { :git => 'https://github.com/chuseok22/capacitor-kakao-login.git', :tag => s.version.to_s }
12
+ s.source_files = 'ios/Sources/**/*.swift'
13
+ s.ios.deployment_target = '13.0'
14
+ s.swift_version = '5.9'
15
+ s.dependency 'Capacitor'
16
+ s.dependency 'KakaoSDKAuth', '~> 2.23'
17
+ s.dependency 'KakaoSDKUser', '~> 2.23'
18
+ end
package/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # @chuseok22/capacitor-kakao-login
2
+
3
+ Capacitor 앱에서 카카오 소셜 로그인을 `npm install` + `npx cap sync` 만으로 쉽게 사용할 수 있는 플러그인입니다. iOS와 Android 모두 지원합니다.
4
+
5
+ ## 왜 이 패키지가 필요한가
6
+
7
+ `npx cap sync` 실행 시 Capacitor CLI는 `node_modules/` 내 npm 패키지만 플러그인으로 스캔합니다. 로컬 Swift 파일은 자동으로 `packageClassList`에 등록되지 않아 `UNIMPLEMENTED` 에러가 발생합니다. 이 패키지는 올바른 Capacitor 플러그인 구조를 갖추어 `npx cap sync`만으로 자동 등록되게 합니다.
8
+
9
+ ## 설치
10
+
11
+ ```bash
12
+ npm install @chuseok22/capacitor-kakao-login
13
+ npx cap sync
14
+ ```
15
+
16
+ ## 사용법
17
+
18
+ ```typescript
19
+ import { KakaoLogin } from '@chuseok22/capacitor-kakao-login';
20
+
21
+ try {
22
+ const { socialId } = await KakaoLogin.login();
23
+ console.log('카카오 사용자 ID:', socialId);
24
+ } catch (error) {
25
+ console.error('카카오 로그인 실패:', error);
26
+ }
27
+ ```
28
+
29
+ ## iOS 설정
30
+
31
+ ### 1. KakaoSDK 초기화 (`AppDelegate.swift`)
32
+
33
+ ```swift
34
+ import KakaoSDKCommon
35
+
36
+ func application(_ application: UIApplication,
37
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
38
+ KakaoSDK.initSDK(appKey: "YOUR_NATIVE_APP_KEY")
39
+ return true
40
+ }
41
+ ```
42
+
43
+ ### 2. URL 핸들러 등록 (`AppDelegate.swift`)
44
+
45
+ ```swift
46
+ import KakaoSDKAuth
47
+
48
+ func application(_ app: UIApplication, open url: URL,
49
+ options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
50
+ if AuthApi.isKakaoTalkLoginUrl(url) {
51
+ return AuthController.handleOpenUrl(url: url)
52
+ }
53
+ return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
54
+ }
55
+ ```
56
+
57
+ ### 3. `Info.plist` 설정
58
+
59
+ 카카오톡 앱 연동 및 URL 스킴을 등록합니다.
60
+
61
+ ```xml
62
+ <!-- 카카오톡 앱 링크 허용 -->
63
+ <key>LSApplicationQueriesSchemes</key>
64
+ <array>
65
+ <string>kakaokompassauth</string>
66
+ <string>storykompassauth</string>
67
+ <string>kakaolink</string>
68
+ </array>
69
+
70
+ <!-- 앱 URL 스킴 등록 (kakao + 네이티브 앱 키) -->
71
+ <key>CFBundleURLTypes</key>
72
+ <array>
73
+ <dict>
74
+ <key>CFBundleURLSchemes</key>
75
+ <array>
76
+ <string>kakao{NATIVE_APP_KEY}</string>
77
+ </array>
78
+ </dict>
79
+ </array>
80
+ ```
81
+
82
+ `{NATIVE_APP_KEY}`를 [카카오 개발자 콘솔](https://developers.kakao.com)의 네이티브 앱 키로 교체하세요.
83
+
84
+ ## Android 설정
85
+
86
+ ### 1. KakaoSDK 초기화 (`Application` 클래스)
87
+
88
+ `Application` 서브클래스를 생성하고 KakaoSDK를 초기화합니다.
89
+
90
+ ```kotlin
91
+ import com.kakao.sdk.common.KakaoSdk
92
+
93
+ class MyApplication : Application() {
94
+ override fun onCreate() {
95
+ super.onCreate()
96
+ KakaoSdk.init(this, "YOUR_NATIVE_APP_KEY")
97
+ }
98
+ }
99
+ ```
100
+
101
+ `AndroidManifest.xml`에 Application 클래스를 등록합니다:
102
+
103
+ ```xml
104
+ <application
105
+ android:name=".MyApplication"
106
+ ...>
107
+ ```
108
+
109
+ ### 2. `AndroidManifest.xml` — 카카오 로그인 Activity 등록
110
+
111
+ 카카오 계정 웹뷰 로그인 후 앱으로 돌아오기 위한 Activity를 등록합니다.
112
+
113
+ ```xml
114
+ <activity
115
+ android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
116
+ android:exported="true">
117
+ <intent-filter>
118
+ <action android:name="android.intent.action.VIEW" />
119
+ <category android:name="android.intent.category.DEFAULT" />
120
+ <category android:name="android.intent.category.BROWSABLE" />
121
+ <data
122
+ android:host="oauth"
123
+ android:scheme="kakao{NATIVE_APP_KEY}" />
124
+ </intent-filter>
125
+ </activity>
126
+ ```
127
+
128
+ `{NATIVE_APP_KEY}`를 [카카오 개발자 콘솔](https://developers.kakao.com)의 네이티브 앱 키로 교체하세요.
129
+
130
+ ## API
131
+
132
+ ### `login() → Promise<KakaoLoginResult>`
133
+
134
+ 카카오 로그인을 실행합니다.
135
+
136
+ - 카카오톡 앱이 설치된 경우: 카카오톡 앱을 통한 로그인
137
+ - 미설치 시: 카카오 계정 웹뷰 로그인
138
+
139
+ **반환값:**
140
+
141
+ ```typescript
142
+ interface KakaoLoginResult {
143
+ /** 카카오 회원 고유 ID. 서버 사용자 식별에 사용합니다. */
144
+ socialId: string;
145
+ }
146
+ ```
147
+
148
+ **에러:**
149
+
150
+ | 에러 메시지 | 원인 |
151
+ |------------|------|
152
+ | `카카오 로그인 실패: ...` | 사용자 취소 또는 카카오 인증 오류 |
153
+ | `사용자 정보 조회 실패: ...` | 카카오 API 호출 오류 |
154
+ | `카카오 사용자 ID를 가져올 수 없습니다` | 예상치 못한 응답 형식 |
155
+
156
+ ## 지원 플랫폼
157
+
158
+ | 플랫폼 | 지원 |
159
+ |--------|------|
160
+ | iOS | ✅ iOS 13+ |
161
+ | Android | ✅ API 22+ |
162
+ | Web | ❌ 미지원 (네이티브 전용) |
163
+
164
+ ## License
165
+
166
+ MIT
@@ -0,0 +1,44 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+
4
+ android {
5
+ namespace "com.capacitorkakaologin"
6
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
7
+ defaultConfig {
8
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
9
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
10
+ versionCode 1
11
+ versionName "1.0"
12
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13
+ }
14
+ buildTypes {
15
+ release {
16
+ minifyEnabled false
17
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18
+ }
19
+ }
20
+ lint {
21
+ abortOnError false
22
+ }
23
+ compileOptions {
24
+ sourceCompatibility JavaVersion.VERSION_17
25
+ targetCompatibility JavaVersion.VERSION_17
26
+ }
27
+ kotlinOptions {
28
+ jvmTarget = '17'
29
+ }
30
+ }
31
+
32
+ repositories {
33
+ google()
34
+ mavenCentral()
35
+ // Kakao Android SDK — Maven Central에 없으므로 별도 저장소 필수
36
+ maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
37
+ }
38
+
39
+ dependencies {
40
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
41
+ implementation project(':capacitor-android')
42
+ // 카카오 로그인 모듈만 포함 (불필요한 모듈 제외)
43
+ implementation "com.kakao.sdk:v2-user:2.20.6"
44
+ }
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+ </manifest>
@@ -0,0 +1,56 @@
1
+ package com.capacitorkakaologin
2
+
3
+ import com.getcapacitor.JSObject
4
+ import com.getcapacitor.Plugin
5
+ import com.getcapacitor.PluginCall
6
+ import com.getcapacitor.PluginMethod
7
+ import com.getcapacitor.annotation.CapacitorPlugin
8
+ import com.kakao.sdk.auth.model.OAuthToken
9
+ import com.kakao.sdk.user.UserApiClient
10
+
11
+ // name 값은 TypeScript registerPlugin('KakaoLogin', ...) 과 반드시 일치해야 한다
12
+ @CapacitorPlugin(name = "KakaoLogin")
13
+ class KakaoLoginPlugin : Plugin() {
14
+
15
+ @PluginMethod
16
+ fun login(call: PluginCall) {
17
+ // ApplicationContext 대신 Activity 사용 — startActivity() 호출이 내부적으로 필요하기 때문
18
+ val activity = activity ?: run {
19
+ call.reject("Activity를 사용할 수 없습니다")
20
+ return
21
+ }
22
+
23
+ // OAuthToken 콜백 — 앱/계정 로그인 공통 처리
24
+ val callback: (OAuthToken?, Throwable?) -> Unit = callback@{ _, error ->
25
+ if (error != null) {
26
+ call.reject("카카오 로그인 실패: ${error.message}")
27
+ return@callback
28
+ }
29
+
30
+ UserApiClient.instance.me { user, meError ->
31
+ if (meError != null) {
32
+ call.reject("사용자 정보 조회 실패: ${meError.message}")
33
+ return@me
34
+ }
35
+
36
+ val userId = user?.id
37
+ if (userId == null) {
38
+ call.reject("카카오 사용자 ID를 가져올 수 없습니다")
39
+ return@me
40
+ }
41
+
42
+ val result = JSObject()
43
+ result.put("socialId", userId.toString())
44
+ call.resolve(result)
45
+ }
46
+ }
47
+
48
+ if (UserApiClient.instance.isKakaoTalkLoginAvailable(activity)) {
49
+ // 카카오톡 앱 설치 시 앱 로그인 우선 시도
50
+ UserApiClient.instance.loginWithKakaoTalk(activity, callback = callback)
51
+ } else {
52
+ // 카카오톡 미설치 시 카카오 계정 웹뷰 로그인으로 폴백
53
+ UserApiClient.instance.loginWithKakaoAccount(activity, callback = callback)
54
+ }
55
+ }
56
+ }
@@ -0,0 +1 @@
1
+ export declare const APP_VERSION: string;
@@ -0,0 +1,2 @@
1
+ export const APP_VERSION = '0.1.1';
2
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/constants/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAW,OAAO,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface KakaoLoginPlugin {
2
+ /**
3
+ * 카카오 로그인을 실행한다.
4
+ * - 카카오톡 앱이 설치된 경우: 앱을 통한 로그인
5
+ * - 미설치 시: 카카오 계정 웹뷰 로그인
6
+ * @returns 카카오 사용자 고유 ID (socialId)
7
+ */
8
+ login(): Promise<KakaoLoginResult>;
9
+ }
10
+ export interface KakaoLoginResult {
11
+ /** 카카오 회원 고유 ID. 서버에 전달하여 사용자 식별에 사용한다. */
12
+ socialId: string;
13
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { KakaoLoginPlugin } from './definitions';
2
+ declare const KakaoLogin: KakaoLoginPlugin;
3
+ export * from './definitions';
4
+ export { KakaoLogin };
@@ -0,0 +1,8 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ // 플러그인 등록명은 iOS jsName 및 Android @CapacitorPlugin(name) 과 반드시 일치해야 한다.
3
+ const KakaoLogin = registerPlugin('KakaoLogin', {
4
+ web: () => import('./web').then(m => new m.KakaoLoginWeb()),
5
+ });
6
+ export * from './definitions';
7
+ export { KakaoLogin };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,uEAAuE;AACvE,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { KakaoLoginPlugin, KakaoLoginResult } from './definitions';
3
+ export declare class KakaoLoginWeb extends WebPlugin implements KakaoLoginPlugin {
4
+ login(): Promise<KakaoLoginResult>;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ // 카카오 로그인은 네이티브 앱 환경 전용이므로, 웹 구현체는 unimplemented 에러를 던진다.
3
+ export class KakaoLoginWeb extends WebPlugin {
4
+ async login() {
5
+ throw this.unimplemented('카카오 로그인은 네이티브 앱 환경에서만 지원됩니다.');
6
+ }
7
+ }
8
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,0DAA0D;AAC1D,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC,CAAC;IAC3D,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ // 플러그인 등록명은 iOS jsName 및 Android @CapacitorPlugin(name) 과 반드시 일치해야 한다.
6
+ const KakaoLogin = core.registerPlugin('KakaoLogin', {
7
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.KakaoLoginWeb()),
8
+ });
9
+
10
+ // 카카오 로그인은 네이티브 앱 환경 전용이므로, 웹 구현체는 unimplemented 에러를 던진다.
11
+ class KakaoLoginWeb extends core.WebPlugin {
12
+ async login() {
13
+ throw this.unimplemented('카카오 로그인은 네이티브 앱 환경에서만 지원됩니다.');
14
+ }
15
+ }
16
+
17
+ var web = /*#__PURE__*/Object.freeze({
18
+ __proto__: null,
19
+ KakaoLoginWeb: KakaoLoginWeb
20
+ });
21
+
22
+ exports.KakaoLogin = KakaoLogin;
23
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n// 플러그인 등록명은 iOS jsName 및 Android @CapacitorPlugin(name) 과 반드시 일치해야 한다.\nconst KakaoLogin = registerPlugin('KakaoLogin', {\n web: () => import('./web').then(m => new m.KakaoLoginWeb()),\n});\nexport * from './definitions';\nexport { KakaoLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n// 카카오 로그인은 네이티브 앱 환경 전용이므로, 웹 구현체는 unimplemented 에러를 던진다.\nexport class KakaoLoginWeb extends WebPlugin {\n async login() {\n throw this.unimplemented('카카오 로그인은 네이티브 앱 환경에서만 지원됩니다.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACA;AACK,MAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACHD;AACO,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC;AAChE,IAAI;AACJ;;;;;;;;;"}
@@ -0,0 +1,21 @@
1
+ import { registerPlugin, WebPlugin } from '@capacitor/core';
2
+
3
+ // 플러그인 등록명은 iOS jsName 및 Android @CapacitorPlugin(name) 과 반드시 일치해야 한다.
4
+ const KakaoLogin = registerPlugin('KakaoLogin', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.KakaoLoginWeb()),
6
+ });
7
+
8
+ // 카카오 로그인은 네이티브 앱 환경 전용이므로, 웹 구현체는 unimplemented 에러를 던진다.
9
+ class KakaoLoginWeb extends WebPlugin {
10
+ async login() {
11
+ throw this.unimplemented('카카오 로그인은 네이티브 앱 환경에서만 지원됩니다.');
12
+ }
13
+ }
14
+
15
+ var web = /*#__PURE__*/Object.freeze({
16
+ __proto__: null,
17
+ KakaoLoginWeb: KakaoLoginWeb
18
+ });
19
+
20
+ export { KakaoLogin };
21
+ //# sourceMappingURL=plugin.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.esm.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n// 플러그인 등록명은 iOS jsName 및 Android @CapacitorPlugin(name) 과 반드시 일치해야 한다.\nconst KakaoLogin = registerPlugin('KakaoLogin', {\n web: () => import('./web').then(m => new m.KakaoLoginWeb()),\n});\nexport * from './definitions';\nexport { KakaoLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n// 카카오 로그인은 네이티브 앱 환경 전용이므로, 웹 구현체는 unimplemented 에러를 던진다.\nexport class KakaoLoginWeb extends WebPlugin {\n async login() {\n throw this.unimplemented('카카오 로그인은 네이티브 앱 환경에서만 지원됩니다.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":[],"mappings":";;AACA;AACK,MAAC,UAAU,GAAG,cAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACHD;AACO,MAAM,aAAa,SAAS,SAAS,CAAC;AAC7C,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC;AAChE,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,26 @@
1
+ var capacitorKakaoLogin = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ // 플러그인 등록명은 iOS jsName 및 Android @CapacitorPlugin(name) 과 반드시 일치해야 한다.
5
+ const KakaoLogin = core.registerPlugin('KakaoLogin', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.KakaoLoginWeb()),
7
+ });
8
+
9
+ // 카카오 로그인은 네이티브 앱 환경 전용이므로, 웹 구현체는 unimplemented 에러를 던진다.
10
+ class KakaoLoginWeb extends core.WebPlugin {
11
+ async login() {
12
+ throw this.unimplemented('카카오 로그인은 네이티브 앱 환경에서만 지원됩니다.');
13
+ }
14
+ }
15
+
16
+ var web = /*#__PURE__*/Object.freeze({
17
+ __proto__: null,
18
+ KakaoLoginWeb: KakaoLoginWeb
19
+ });
20
+
21
+ exports.KakaoLogin = KakaoLogin;
22
+
23
+ return exports;
24
+
25
+ })({}, capacitorExports);
26
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n// 플러그인 등록명은 iOS jsName 및 Android @CapacitorPlugin(name) 과 반드시 일치해야 한다.\nconst KakaoLogin = registerPlugin('KakaoLogin', {\n web: () => import('./web').then(m => new m.KakaoLoginWeb()),\n});\nexport * from './definitions';\nexport { KakaoLogin };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n// 카카오 로그인은 네이티브 앱 환경 전용이므로, 웹 구현체는 unimplemented 에러를 던진다.\nexport class KakaoLoginWeb extends WebPlugin {\n async login() {\n throw this.unimplemented('카카오 로그인은 네이티브 앱 환경에서만 지원됩니다.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IACA;AACK,UAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IAC/D,CAAC;;ICHD;IACO,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC;IAChE,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,29 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "KakaoLoginPlugin",
6
+ platforms: [.iOS(.v13)],
7
+ products: [
8
+ .library(
9
+ name: "KakaoLoginPlugin",
10
+ targets: ["KakaoLoginPlugin"]
11
+ )
12
+ ],
13
+ dependencies: [
14
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "6.0.0"),
15
+ .package(url: "https://github.com/kakao/kakao-ios-sdk", from: "2.23.0"),
16
+ ],
17
+ targets: [
18
+ .target(
19
+ name: "KakaoLoginPlugin",
20
+ dependencies: [
21
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
22
+ .product(name: "Cordova", package: "capacitor-swift-pm"),
23
+ .product(name: "KakaoSDKAuth", package: "kakao-ios-sdk"),
24
+ .product(name: "KakaoSDKUser", package: "kakao-ios-sdk"),
25
+ ],
26
+ path: "Sources/KakaoLoginPlugin"
27
+ )
28
+ ]
29
+ )
@@ -0,0 +1,57 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import KakaoSDKAuth
4
+ import KakaoSDKUser
5
+
6
+ /// Capacitor 플러그인 — 카카오 소셜 로그인
7
+ /// npx cap sync 시 @objc(KakaoLoginPlugin) 패턴으로 자동 탐색된다.
8
+ @objc(KakaoLoginPlugin)
9
+ public class KakaoLoginPlugin: CAPPlugin, CAPBridgedPlugin {
10
+
11
+ public let identifier = "KakaoLoginPlugin"
12
+ public let jsName = "KakaoLogin"
13
+ public let pluginMethods: [CAPPluginMethod] = [
14
+ CAPPluginMethod(name: "login", returnType: CAPPluginReturnPromise)
15
+ ]
16
+
17
+ @objc func login(_ call: CAPPluginCall) {
18
+ DispatchQueue.main.async {
19
+ if UserApi.isKakaoTalkLoginAvailable() {
20
+ // 카카오톡 앱 로그인
21
+ UserApi.shared.loginWithKakaoTalk { [weak self] oauthToken, error in
22
+ self?.handleLoginResult(call: call, oauthToken: oauthToken, error: error)
23
+ }
24
+ } else {
25
+ // 카카오 계정 웹뷰 로그인 (카카오톡 미설치 환경)
26
+ UserApi.shared.loginWithKakaoAccount { [weak self] oauthToken, error in
27
+ self?.handleLoginResult(call: call, oauthToken: oauthToken, error: error)
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ private func handleLoginResult(call: CAPPluginCall, oauthToken _: OAuthToken?, error: Error?) {
34
+ if let error = error {
35
+ DispatchQueue.main.async {
36
+ call.reject("카카오 로그인 실패", nil, error)
37
+ }
38
+ return
39
+ }
40
+
41
+ UserApi.shared.me { user, error in
42
+ DispatchQueue.main.async {
43
+ if let error = error {
44
+ call.reject("카카오 사용자 정보 조회 실패", nil, error)
45
+ return
46
+ }
47
+
48
+ guard let userId = user?.id else {
49
+ call.reject("카카오 사용자 ID를 가져올 수 없습니다")
50
+ return
51
+ }
52
+
53
+ call.resolve(["socialId": String(userId)])
54
+ }
55
+ }
56
+ }
57
+ }
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@chuseok22/capacitor-kakao-login",
3
+ "version": "0.1.1",
4
+ "description": "Capacitor plugin for Kakao social login (iOS & Android)",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/plugin.esm.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "dist/",
11
+ "ios/",
12
+ "android/",
13
+ "CapacitorKakaoLogin.podspec"
14
+ ],
15
+ "author": "Baek Jihoon",
16
+ "license": "MIT",
17
+ "type": "module",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/chuseok22/capacitor-kakao-login.git"
21
+ },
22
+ "keywords": [
23
+ "capacitor",
24
+ "plugin",
25
+ "kakao",
26
+ "kakao-login",
27
+ "social-login",
28
+ "ios",
29
+ "android"
30
+ ],
31
+ "scripts": {
32
+ "build": "npm run clean && tsc && rollup -c rollup.config.js",
33
+ "clean": "rimraf ./dist",
34
+ "lint": "eslint . --ext ts",
35
+ "fmt": "prettier --write --parser typescript 'src/**/*.ts'",
36
+ "verify:web": "npm run build"
37
+ },
38
+ "devDependencies": {
39
+ "@capacitor/android": "^6.0.0",
40
+ "@capacitor/core": "^6.0.0",
41
+ "@capacitor/ios": "^6.0.0",
42
+ "@ionic/eslint-config": "^0.3.0",
43
+ "@ionic/prettier-config": "~1.0.1",
44
+ "@rollup/plugin-node-resolve": "^15.0.0",
45
+ "eslint": "^7.32.0",
46
+ "prettier": "~2.3.2",
47
+ "rimraf": "^5.0.0",
48
+ "rollup": "^4.0.0",
49
+ "typescript": "~5.1.3"
50
+ },
51
+ "peerDependencies": {
52
+ "@capacitor/core": ">=6.0.0"
53
+ },
54
+ "capacitor": {
55
+ "ios": {
56
+ "src": "ios"
57
+ },
58
+ "android": {
59
+ "src": "android"
60
+ }
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }