From 9cf489e0a9c4eec273248d7973405b2e7c7e397a Mon Sep 17 00:00:00 2001 From: hooni Date: Sat, 31 Aug 2024 22:12:54 +0900 Subject: [PATCH] =?UTF-8?q?feat/#350=20=EC=B9=B4=EC=B9=B4=EC=98=A4?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B5=AC=ED=98=84=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KkuMulKum.xcodeproj/project.pbxproj | 7 ------ .../xcshareddata/xcschemes/KkuMulKum.xcscheme | 9 ++++++- KkuMulKum/Application/AppDelegate.swift | 25 ++++++------------- KkuMulKum/Application/SceneDelegate.swift | 8 +++--- .../Login/VIewModel/LoginViewModel.swift | 9 +++++++ 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/KkuMulKum.xcodeproj/project.pbxproj b/KkuMulKum.xcodeproj/project.pbxproj index 89ccf10b..76852aa9 100644 --- a/KkuMulKum.xcodeproj/project.pbxproj +++ b/KkuMulKum.xcodeproj/project.pbxproj @@ -1213,13 +1213,6 @@ path = Tardy; sourceTree = ""; }; - DD9F59642C7C7E3B00E928DF /* Recovered References */ = { - isa = PBXGroup; - children = ( - ); - name = "Recovered References"; - sourceTree = ""; - }; DD9F59652C7C7E5C00E928DF /* Cell */ = { isa = PBXGroup; children = ( diff --git a/KkuMulKum.xcodeproj/xcshareddata/xcschemes/KkuMulKum.xcscheme b/KkuMulKum.xcodeproj/xcshareddata/xcschemes/KkuMulKum.xcscheme index 55aba682..1570b9c9 100644 --- a/KkuMulKum.xcodeproj/xcshareddata/xcschemes/KkuMulKum.xcscheme +++ b/KkuMulKum.xcodeproj/xcshareddata/xcschemes/KkuMulKum.xcscheme @@ -30,7 +30,7 @@ shouldAutocreateTestPlan = "YES"> + + + + 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, @@ -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 { diff --git a/KkuMulKum/Application/SceneDelegate.swift b/KkuMulKum/Application/SceneDelegate.swift index f7e6211a..481d791c 100644 --- a/KkuMulKum/Application/SceneDelegate.swift +++ b/KkuMulKum/Application/SceneDelegate.swift @@ -39,12 +39,12 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { - 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, diff --git a/KkuMulKum/Source/Onboarding/Login/VIewModel/LoginViewModel.swift b/KkuMulKum/Source/Onboarding/Login/VIewModel/LoginViewModel.swift index daff4861..b46af2a9 100644 --- a/KkuMulKum/Source/Onboarding/Login/VIewModel/LoginViewModel.swift +++ b/KkuMulKum/Source/Onboarding/Login/VIewModel/LoginViewModel.swift @@ -10,6 +10,7 @@ import AuthenticationServices import KakaoSDKUser import KakaoSDKAuth +import KakaoSDKCommon import Moya import FirebaseMessaging @@ -29,6 +30,8 @@ class LoginViewModel: NSObject { private let authInterceptor: AuthInterceptor private let keychainAccessible: KeychainAccessible + private let kakaoAppKey: String + init( provider: MoyaProvider = MoyaProvider( plugins: [NetworkLoggerPlugin(configuration: .init(logOptions: .verbose))] @@ -36,6 +39,12 @@ class LoginViewModel: NSObject { 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)