From 7f32e54f286b30223cd090fccb082c90172e2044 Mon Sep 17 00:00:00 2001 From: yungu0010 Date: Mon, 8 Jan 2024 14:24:06 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20#206=20-=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81=20-=20changeRootViewControllerTo?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20-=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iOS-NOTTODO/Application/AppDelegate.swift | 15 ---------- .../Auth/AuthViewController.swift | 28 ++++--------------- .../MyInfoAccountViewController.swift | 9 ++---- .../FifthOnboardingViewController.swift | 5 +--- 4 files changed, 9 insertions(+), 48 deletions(-) diff --git a/iOS-NOTTODO/iOS-NOTTODO/Application/AppDelegate.swift b/iOS-NOTTODO/iOS-NOTTODO/Application/AppDelegate.swift index b61d4a3d..897387f2 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Application/AppDelegate.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Application/AppDelegate.swift @@ -31,9 +31,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if KeychainUtil.getAccessToken() != "" { self.skipAuthView() print("토큰 유효") - } else { - // self.showAuthView() - // 토큰이 유효하지 않을 경우 일단은 온보딩->로그인->홈 이렇게만 가도록 } // 메시지 대리자 설정 @@ -48,18 +45,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } - func showAuthView() { - DispatchQueue.main.async { - if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, - let window = windowScene.windows.first { - let authViewController = AuthViewController() - let navigationController = UINavigationController(rootViewController: authViewController) - window.rootViewController = navigationController - window.makeKeyAndVisible() - } - } - } - func skipAuthView() { // 홈 화면으로 바로 이동 DispatchQueue.main.async { diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift index be12b16d..33af0b2b 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift @@ -242,7 +242,6 @@ extension AuthViewController { KeychainUtil.setAccessToken(accessToken) Amplitude.instance().setUserId(userId) self?.checkNotificationSettings() - } } } @@ -250,16 +249,9 @@ extension AuthViewController { func presentToHomeViewController() { DispatchQueue.main.async { - if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, - let window = windowScene.windows.first { - let tabBarController = TabBarController() - let navigationController = UINavigationController(rootViewController: tabBarController) - navigationController.isNavigationBarHidden = true - window.rootViewController = navigationController - window.makeKeyAndVisible() - } + SceneDelegate.shared?.changeRootViewControllerTo(TabBarController()) } - } + } func checkNotificationSettings() { UNUserNotificationCenter.current().getNotificationSettings { settings in @@ -274,26 +266,18 @@ extension AuthViewController { func showNotiDialogView() { DispatchQueue.main.async { - if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, - let window = windowScene.windows.first { - let notiDialogViewController = NotificationDialogViewController() - notiDialogViewController.buttonHandler = { - self.requestNotification() - } - let navigationController = UINavigationController(rootViewController: notiDialogViewController) - navigationController.isNavigationBarHidden = true - window.rootViewController = navigationController - window.makeKeyAndVisible() + let notiDialogViewController = NotificationDialogViewController() + notiDialogViewController.buttonHandler = { + self.requestNotification() } + SceneDelegate.shared?.changeRootViewControllerTo(notiDialogViewController) } } func requestNotification() { -// UNUserNotificationCenter.current().delegate = self let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: { _, _ in self.presentToHomeViewController() - }) } } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift index bc26d58f..d2c1af64 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/MyInfoAccount/ViewControllers/MyInfoAccountViewController.swift @@ -180,16 +180,11 @@ extension MyInfoAccountViewController { if !UserDefaults.standard.bool(forKey: DefaultKeys.isAppleLogin) { kakaoLogout() } - AuthAPI.shared.deleteAuth { [weak self] _ in + AuthAPI.shared.deleteAuth { _ in UserDefaults.standard.removeObject(forKey: DefaultKeys.accessToken) UserDefaults.standard.removeObject(forKey: DefaultKeys.socialToken) AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.AccountInfo.completeLogout) - let authViewController = AuthViewController() - if let window = self?.view.window?.windowScene?.keyWindow { - let navigationController = UINavigationController(rootViewController: authViewController) - navigationController.isNavigationBarHidden = true - window.rootViewController = navigationController - } + SceneDelegate.shared?.changeRootViewControllerTo(AuthViewController()) } } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Onboarding/ViewControllers/FifthOnboardingViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Onboarding/ViewControllers/FifthOnboardingViewController.swift index 8c75c522..01bfe566 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Onboarding/ViewControllers/FifthOnboardingViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Onboarding/ViewControllers/FifthOnboardingViewController.swift @@ -184,10 +184,7 @@ extension FifthOnboardingViewController { if let window = view.window?.windowScene?.keyWindow { DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { UIView.animate(withDuration: 0.01) { - let TabBarController = AuthViewController() - let navigationController = UINavigationController(rootViewController: TabBarController) - navigationController.isNavigationBarHidden = true - window.rootViewController = navigationController + SceneDelegate.shared?.changeRootViewControllerTo(AuthViewController()) } } }