Skip to content

Commit 865a97a

Browse files
authored
Feat: 카카오 로그인 구현 (#T3-66)
[Feat-T3-66] 카카오 로그인 구현
2 parents 94be5f8 + 49ed360 commit 865a97a

27 files changed

Lines changed: 501 additions & 54 deletions

Projects/App/Sources/AppDelegate.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,25 @@
66
//
77

88
import UIKit
9+
import DataSource
10+
import KakaoSDKCommon
911

1012
@main
1113
class AppDelegate: UIResponder, UIApplicationDelegate {
1214

1315
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
14-
// Override point for customization after application launch.
16+
KakaoSDK.initSDK(appKey: AppProperties.kakaoNativeKey)
1517
return true
1618
}
1719

1820
// MARK: UISceneSession Lifecycle
1921
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
20-
// Called when a new scene session is being created.
21-
// Use this method to select a configuration to create the new scene with.
22+
2223
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
2324
}
2425

2526
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
26-
// Called when the user discards a scene session.
27-
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
28-
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
27+
2928
}
3029
}
3130

Projects/App/Sources/SceneDelegate.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import UIKit
9+
import KakaoSDKAuth
910
import Presentation
1011
import Shared
1112

@@ -17,18 +18,29 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1718
let window = UIWindow(windowScene: windowScene)
1819

1920
DIContainer.shared.dependencyInjection()
20-
guard let homeViewModel = DIContainer.shared.resolve(type: HomeViewModel.self) else {
21-
fatalError("homeViewModel 의존성이 등록되지 않았습니다.")
22-
}
21+
// guard let homeViewModel = DIContainer.shared.resolve(type: HomeViewModel.self) else {
22+
// fatalError("homeViewModel 의존성이 등록되지 않았습니다.")
23+
// }
2324

24-
let navigationController = UINavigationController(rootViewController: HomeViewController(viewModel: homeViewModel))
25+
guard let loginViewModel = DIContainer.shared.resolve(type: LoginViewModel.self) else {
26+
fatalError("loginViewModel 의존성이 등록되지 않았습니다.")
27+
}
28+
let navigationController = UINavigationController(rootViewController: LoginViewController(viewModel: loginViewModel))
2529
navigationController.isNavigationBarHidden = true
2630
window.rootViewController = navigationController
2731
window.makeKeyAndVisible()
2832

2933
self.window = window
3034
}
3135

36+
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
37+
if let url = URLContexts.first?.url {
38+
if (AuthApi.isKakaoTalkLoginUrl(url)) {
39+
_ = AuthController.handleOpenUrl(url: url)
40+
}
41+
}
42+
}
43+
3244
func sceneDidDisconnect(_ scene: UIScene) {
3345
}
3446

Projects/DataSource/Project.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ let project = Project(
1313
dependencies: [
1414
.project(target: "Domain", path: "../Domain"),
1515
.project(target: "Shared", path: "../Shared"),
16+
.external(name: "KakaoSDKCommon"),
17+
.external(name: "KakaoSDKAuth"),
18+
.external(name: "KakaoSDKUser"),
1619
]
1720
)
1821
]

Projects/DataSource/Sources/DataSourceDependencyAssembler.swift renamed to Projects/DataSource/Sources/Common/DataSourceDependencyAssembler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@ public struct DataSourceDependencyAssembler: DependencyAssemblerProtocol {
3030
DIContainer.shared.register(type: TestRepositoryProtocol.self) { _ in
3131
return TestRepository(networkService: networkService)
3232
}
33+
34+
DIContainer.shared.register(type: AuthRepositoryProtocol.self) { _ in
35+
return AuthRepository(networkService: networkService, keychainStorage: keychainStorage)
36+
}
3337
}
3438
}

Projects/DataSource/Sources/Network/AppProperties.swift renamed to Projects/DataSource/Sources/Common/Enum/AppProperties.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
import Foundation
99

10-
enum AppProperties {
10+
public enum AppProperties {
1111
static var baseURL: String {
1212
Bundle.main.object(forInfoDictionaryKey: "BaseURL") as? String ?? ""
1313
}
14+
15+
public static var kakaoNativeKey: String {
16+
Bundle.main.object(forInfoDictionaryKey: "KakaoNativeKey") as? String ?? ""
17+
}
1418
}

Projects/DataSource/Sources/Network/Endpoint.swift renamed to Projects/DataSource/Sources/Common/Enum/Endpoint.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
// Created by 최정인 on 6/21/25.
66
//
77

8-
import Foundation
9-
108
public protocol Endpoint {
119
var baseURL: String { get }
1210
var path: String { get }
1311
var method: HTTPMethod { get }
1412
var headers: [String: String] { get }
15-
var parameters: [String: Any] { get }
13+
var queryParameters: [String: String] { get }
14+
var bodyParameters: [String: Any] { get }
1615
}

Projects/DataSource/Sources/Network/HTTPMethod.swift renamed to Projects/DataSource/Sources/Common/Enum/HTTPMethod.swift

File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// SocialLoginType.swift
3+
// DataSource
4+
//
5+
// Created by 최정인 on 6/30/25.
6+
//
7+
8+
enum SocialLoginType: String {
9+
case kakao = "KAKAO"
10+
case apple = "APPLE"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// TokenType.swift
3+
// DataSource
4+
//
5+
// Created by 최정인 on 6/30/25.
6+
//
7+
8+
enum TokenType: String {
9+
case accessToken = "AccessToken"
10+
case refreshToken = "RefreshToken"
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// AuthError.swift
3+
// DataSource
4+
//
5+
// Created by 최정인 on 6/30/25.
6+
//
7+
8+
enum AuthError: Error, CustomStringConvertible {
9+
case failTokenSave
10+
11+
public var description: String {
12+
switch self {
13+
case .failTokenSave:
14+
return "토큰 저장에 실패했습니다."
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)