Skip to content

Commit

Permalink
Merge pull request #351 from OMZigak/hotfix/#350-kakaoSolve
Browse files Browse the repository at this point in the history
feat/#350 카카오로그인 구현완료
  • Loading branch information
hooni0918 authored Sep 2, 2024
2 parents 6389618 + 9cf489e commit e960117
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
7 changes: 0 additions & 7 deletions KkuMulKum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1213,13 +1213,6 @@
path = Tardy;
sourceTree = "<group>";
};
DD9F59642C7C7E3B00E928DF /* Recovered References */ = {
isa = PBXGroup;
children = (
);
name = "Recovered References";
sourceTree = "<group>";
};
DD9F59652C7C7E5C00E928DF /* Cell */ = {
isa = PBXGroup;
children = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand All @@ -49,6 +49,13 @@
ReferencedContainer = "container:KkuMulKum.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "IDEPreferLogStreaming"
value = "YES"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
25 changes: 8 additions & 17 deletions KkuMulKum/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit

import KakaoSDKCommon
import KakaoSDKAuth
import Firebase
Expand All @@ -19,30 +20,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {

UNUserNotificationCenter.current().delegate = LocalNotificationManager.shared

// KakaoSDK 초기화 과정에서 앱 키를 동적으로 불러오기
if let kakaoAppKey = fetchKakaoAppKeyFromPrivacyInfo() {
KakaoSDK.initSDK(appKey: kakaoAppKey)
// KakaoSDK 초기화
if let kakaoAppKey = Bundle.main.privacyInfo?["NATIVE_APP_KEY"] as? String {
KakaoSDK.initSDK(appKey: kakaoAppKey, loggingEnable: true)
print("Kakao SDK initialized with app key: \(kakaoAppKey)")
} else {
print("Failed to load KAKAO_APP_KEY from PrivacyInfo.plist")
}

setupFirebase(application: application)

return true
}

func fetchKakaoAppKeyFromPrivacyInfo() -> String? {
guard let path = Bundle.main.path(forResource: "PrivacyInfo", ofType: "plist"),
let dict = NSDictionary(contentsOfFile: path) as? [String: AnyObject],
let appKey = dict["NATIVE_APP_KEY"] as? String else {
return nil
}
return appKey
}

// 카카오 로그인

// 카카오 로그인 URL 처리 (중복 제거)
func application(
_ app: UIApplication,
open url: URL,
Expand Down Expand Up @@ -117,7 +108,7 @@ extension AppDelegate: MessagingDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken

Messaging.messaging().token { [weak self] token, error in
Messaging.messaging().token { token, error in
if let error = error {
print("Error fetching FCM registration token: \(error)")
} else if let token = token {
Expand Down
8 changes: 4 additions & 4 deletions KkuMulKum/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let url = URLContexts.first?.url {
if (AuthApi.isKakaoTalkLoginUrl(url)) {
_ = AuthController.handleOpenUrl(url: url)
if let url = URLContexts.first?.url {
if (AuthApi.isKakaoTalkLoginUrl(url)) {
_ = AuthController.handleOpenUrl(url: url)
}
}
}
}

func application(
_ app: UIApplication,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import AuthenticationServices

import KakaoSDKUser
import KakaoSDKAuth
import KakaoSDKCommon
import Moya
import FirebaseMessaging

Expand All @@ -29,13 +30,21 @@ class LoginViewModel: NSObject {
private let authInterceptor: AuthInterceptor
private let keychainAccessible: KeychainAccessible

private let kakaoAppKey: String

init(
provider: MoyaProvider<AuthTargetType> = MoyaProvider<AuthTargetType>(
plugins: [NetworkLoggerPlugin(configuration: .init(logOptions: .verbose))]
),
authService: AuthServiceProtocol = AuthService(),
keychainAccessible: KeychainAccessible = DefaultKeychainAccessible()
) {
if let appKey = Bundle.main.privacyInfo?["NATIVE_APP_KEY"] as? String {
self.kakaoAppKey = appKey
} else {
fatalError("Failed to load NATIVE_APP_KEY from PrivacyInfo.plist")
}

self.provider = provider
self.authService = authService
self.authInterceptor = AuthInterceptor(authService: authService, provider: provider)
Expand Down

0 comments on commit e960117

Please sign in to comment.