Skip to content

Commit

Permalink
[Fix] #206 - 코드리뷰 반영
Browse files Browse the repository at this point in the history
- changeRootViewControllerTo로 변경
- 불필요한 코드 수정 및 주석 삭제
  • Loading branch information
yungu0010 committed Jan 8, 2024
1 parent b46df06 commit 7f32e54
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 48 deletions.
15 changes: 0 additions & 15 deletions iOS-NOTTODO/iOS-NOTTODO/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if KeychainUtil.getAccessToken() != "" {
self.skipAuthView()
print("토큰 유효")
} else {
// self.showAuthView()
// 토큰이 유효하지 않을 경우 일단은 온보딩->로그인->홈 이렇게만 가도록
}

// 메시지 대리자 설정
Expand All @@ -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 {
Expand Down
28 changes: 6 additions & 22 deletions iOS-NOTTODO/iOS-NOTTODO/Presentation/Auth/AuthViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,24 +242,16 @@ extension AuthViewController {
KeychainUtil.setAccessToken(accessToken)
Amplitude.instance().setUserId(userId)
self?.checkNotificationSettings()

}
}
}
}

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
Expand All @@ -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()

})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
}
Expand Down

0 comments on commit 7f32e54

Please sign in to comment.