From 6b169fc50dd17971e23087bd53972913553bbce1 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 13:25:36 +0900 Subject: [PATCH 01/14] =?UTF-8?q?[BUGFIX]=20500=EB=B2=88=EB=8C=80=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=20=EC=97=90=EB=9F=AC=20=EB=B0=9C=EC=83=9D=20?= =?UTF-8?q?=EC=8B=9C=EC=97=90=EB=A7=8C=20=EC=8B=9C=EC=8A=A4=ED=85=9C=20?= =?UTF-8?q?=ED=8C=9D=EC=97=85=20=EB=85=B8=EC=B6=9C=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/BaseViewController.swift | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Atcha-iOS/Presentation/Common/BaseViewController.swift b/Atcha-iOS/Presentation/Common/BaseViewController.swift index 7352c9d..f3a7f5a 100644 --- a/Atcha-iOS/Presentation/Common/BaseViewController.swift +++ b/Atcha-iOS/Presentation/Common/BaseViewController.swift @@ -220,12 +220,25 @@ class BaseViewController: UIViewController { object: nil ) } - - @objc private func handleServerError(_ notification: Notification) { - guard self.presentedViewController == nil else { return } - DispatchQueue.main.async { [weak self] in - self?.showAtchaErrorPopup() + @objc private func handleServerError(_ notification: Notification) { + // 1. 전달된 오브젝트가 APIError인지 확인 + guard let apiError = notification.object as? APIError else { return } + + // 2. 에러 케이스와 상태 코드 추출 (APIError가 statusCode를 가지고 있다고 가정) + if case .serverError(let statusCode) = apiError { + + // 3. 500번대 에러인 경우에만 팝업 노출 + if (500...599).contains(statusCode) { + guard self.presentedViewController == nil else { return } + + DispatchQueue.main.async { [weak self] in + self?.showAtchaErrorPopup() + } + } else { + // 400번대 등 기타 에러는 팝업을 띄우지 않고 로그만 남기거나 별도 처리 + print("UI 팝업 제외 대상 에러: \(statusCode)") + } } } From d51c532383bb0f9f21a6879fa23bfd6627443c5b Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 13:29:16 +0900 Subject: [PATCH 02/14] =?UTF-8?q?[BUGFIX]=20=EC=97=90=EB=9F=AC=20=ED=8C=9D?= =?UTF-8?q?=EC=97=85=20=EC=A4=91=EB=B3=B5=20=EB=85=B8=EC=B6=9C=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Atcha-iOS/Presentation/Common/BaseViewController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Atcha-iOS/Presentation/Common/BaseViewController.swift b/Atcha-iOS/Presentation/Common/BaseViewController.swift index f3a7f5a..9b1c764 100644 --- a/Atcha-iOS/Presentation/Common/BaseViewController.swift +++ b/Atcha-iOS/Presentation/Common/BaseViewController.swift @@ -9,6 +9,10 @@ import UIKit import Combine import CoreLocation +private struct ErrorState { + static var isShowing500Error = false +} + class BaseViewController: UIViewController { var activePermissionToast: AtchaActionToast? var activeAlarmPermissionToast: AtchaActionToast? @@ -229,7 +233,7 @@ class BaseViewController: UIViewController { if case .serverError(let statusCode) = apiError { // 3. 500번대 에러인 경우에만 팝업 노출 - if (500...599).contains(statusCode) { + if (500...599).contains(statusCode) && !ErrorState.isShowing500Error { guard self.presentedViewController == nil else { return } DispatchQueue.main.async { [weak self] in @@ -243,11 +247,14 @@ class BaseViewController: UIViewController { } private func showAtchaErrorPopup() { + ErrorState.isShowing500Error = true + // 이전에 만드신 앗차팝업 호출 (에러 케이스용) let popupVM = AtchaPopupViewModel(info: .serverError) // Enum에 .serverError 추가 필요 let popupVC = AtchaPopupViewController(viewModel: popupVM) popupVC.confirmButton.addAction(UIAction { [weak popupVC] _ in + ErrorState.isShowing500Error = false popupVC?.dismiss(animated: false) }, for: .touchUpInside) From 93c7726a8254cedbdc007640dd601dc47fc75a30 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 13:45:17 +0900 Subject: [PATCH 03/14] =?UTF-8?q?[BUGFIX]=20=EC=A7=80=ED=95=98=EC=B2=A0=20?= =?UTF-8?q?=EB=AA=A9=EC=A0=81=EC=A7=80=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EA=B0=80=20=EB=B9=88=20=EB=AC=B8=EC=9E=90=EC=97=B4("")?= =?UTF-8?q?=EC=9D=BC=20=EB=95=8C=20=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DetailRouteInfo/Cell/DetailRouteSubwayCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteInfo/Cell/DetailRouteSubwayCell.swift b/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteInfo/Cell/DetailRouteSubwayCell.swift index 68bcb1d..f0b2dbe 100644 --- a/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteInfo/Cell/DetailRouteSubwayCell.swift +++ b/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteInfo/Cell/DetailRouteSubwayCell.swift @@ -461,7 +461,7 @@ extension DetailRouteSubwayCell { return } - if let destination = matched.destination { + if let destination = matched.destination, destination != "" { subwayDirectionLabel.attributedText = AtchaFont.B6_R_14("\(destination)행", color: .white) } else { subwayDirectionLabel.attributedText = AtchaFont.B6_R_14("", color: .white) From 3adfb3957c7fa7c800ebb2744a5222d522b35db7 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 14:17:11 +0900 Subject: [PATCH 04/14] =?UTF-8?q?[FEAT]=20=EB=9D=BD=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A6=B0=20=EA=B2=80=EC=83=89=20=EC=A7=84=EC=9E=85=20=EC=8B=9C?= =?UTF-8?q?=20=EB=84=A4=EB=B9=84=EA=B2=8C=EC=9D=B4=EC=85=98=20=EC=8A=A4?= =?UTF-8?q?=ED=83=9D=20=EA=B3=84=EC=B8=B5=20=EA=B5=AC=EC=A1=B0=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Course/CourseDIContainer.swift | 5 +-- .../CourseSearchViewController.swift | 14 +++++++- .../CourseSearch/CourseSearchViewModel.swift | 11 +++++- .../Location/Coordinator/MainRoute.swift | 2 +- .../Location/MainViewController.swift | 2 +- .../Presentation/Location/MainViewModel.swift | 5 +-- .../Lock/LockViewController.swift | 2 +- .../Presentation/Main/MainCoordinator.swift | 35 +++++++++++++------ 8 files changed, 57 insertions(+), 19 deletions(-) diff --git a/Atcha-iOS/App/DIContainer/Course/CourseDIContainer.swift b/Atcha-iOS/App/DIContainer/Course/CourseDIContainer.swift index 688bddc..9ef1a20 100644 --- a/Atcha-iOS/App/DIContainer/Course/CourseDIContainer.swift +++ b/Atcha-iOS/App/DIContainer/Course/CourseDIContainer.swift @@ -24,7 +24,7 @@ final class CourseDIContainer { self.tokenStorage = tokenStorage } - func makeCourseSearchViewModel(startLat: String, startLon: String, startAddress: String) -> CourseSearchViewModel { + func makeCourseSearchViewModel(startLat: String, startLon: String, startAddress: String, context: CourseSearchContext) -> CourseSearchViewModel { let courseUseCase = CourseUseCaseImpl( repository: CourseRepositoryImpl(apiService: apiService, tokenStorage: tokenStorage) ) @@ -35,7 +35,8 @@ final class CourseDIContainer { alarmUseCase: alarmUseCase, startLat: startLat, startLon: startLon, - startAddress: startAddress) + startAddress: startAddress, + context: context) } func makeCourseSearchViewController(viewModel: CourseSearchViewModel) -> UIViewController { diff --git a/Atcha-iOS/Presentation/Course/CourseSearch/CourseSearchViewController.swift b/Atcha-iOS/Presentation/Course/CourseSearch/CourseSearchViewController.swift index 8c908ec..ea88086 100644 --- a/Atcha-iOS/Presentation/Course/CourseSearch/CourseSearchViewController.swift +++ b/Atcha-iOS/Presentation/Course/CourseSearch/CourseSearchViewController.swift @@ -13,7 +13,7 @@ final class CourseSearchViewController: BaseViewController { let address = wrapper.string(forKey: UserDefaultsWrapper.Key.startAddress.rawValue) ?? "" amp_track(.later_course_click) - viewModel.routerHandler?(.courseSearch(startLat: lat, startLon: lon, startAddress: address)) + viewModel.routerHandler?(.courseSearch(startLat: lat, startLon: lon, startAddress: address, context: .afterReigster)) } private func observeAlarmTimeout() { diff --git a/Atcha-iOS/Presentation/Main/MainCoordinator.swift b/Atcha-iOS/Presentation/Main/MainCoordinator.swift index 736777a..56e99ca 100644 --- a/Atcha-iOS/Presentation/Main/MainCoordinator.swift +++ b/Atcha-iOS/Presentation/Main/MainCoordinator.swift @@ -93,11 +93,12 @@ final class MainCoordinator: NSObject { } myPageCoordinator.start() - case let .courseSearch(startLat, startLon, startAddress): + case let .courseSearch(startLat, startLon, startAddress, context): let courseDI = diContainer.makeCourseDIContainer() let vm = courseDI.makeCourseSearchViewModel(startLat: startLat, startLon: startLon, - startAddress: startAddress) + startAddress: startAddress, + context: context) let vc = courseDI.makeCourseSearchViewController(viewModel: vm) vm.getAlarmTapped = { [weak self] address, infos in guard let self else { return } @@ -130,7 +131,8 @@ final class MainCoordinator: NSObject { let searchVM = courseDI.makeCourseSearchViewModel( startLat: "\(coordinate.latitude)", startLon: "\(coordinate.longitude)", - startAddress: locationInfo.name ?? "주소 없음" + startAddress: locationInfo.name ?? "주소 없음", + context: .beforeRegister ) searchVM.getAlarmTapped = { [weak self] address, infos in @@ -192,7 +194,8 @@ final class MainCoordinator: NSObject { let searchVM = courseDI.makeCourseSearchViewModel( startLat: "\(coordinate.latitude)", startLon: "\(coordinate.longitude)", - startAddress: locationInfo.name ?? "주소 없음" + startAddress: locationInfo.name ?? "주소 없음", + context: .beforeRegister ) searchVM.getAlarmTapped = { [weak self] address, infos in @@ -234,7 +237,8 @@ final class MainCoordinator: NSObject { let searchVM = courseDI.makeCourseSearchViewModel( startLat: "\(coordinate.latitude)", startLon: "\(coordinate.longitude)", - startAddress: locationInfo.name ?? "주소 없음" + startAddress: locationInfo.name ?? "주소 없음", + context: .beforeRegister ) searchVM.getAlarmTapped = { [weak self] address, infos in @@ -298,11 +302,22 @@ final class MainCoordinator: NSObject { infos: info, context: .afterReigster)) } - case .courseSearch(let startLat, let startLon, let startAddress): - self?.navigationController.dismiss(animated: false) { - self?.handle(route: .courseSearch(startLat: startLat, - startLon: startLon, - startAddress: startAddress)) + case .courseSearch(let startLat, let startLon, let startAddress, _): + self?.navigationController.dismiss(animated: false) { [weak self] in + guard let self = self else { return } + + let wrapper = UserDefaultsWrapper.shared + let currentInfo = wrapper.object(forKey: UserDefaultsWrapper.Key.legInfo.rawValue, of: LegInfo.self) + let currentAddress = wrapper.string(forKey: UserDefaultsWrapper.Key.addressDesc.rawValue) ?? "" + + if let info = currentInfo { + self.handle(route: .detailRoute(address: currentAddress, infos: info, context: .afterReigster)) + } + + self.handle(route: .courseSearch(startLat: startLat, + startLon: startLon, + startAddress: startAddress, + context: .afterReigster)) } case .dismissLockScreen: self?.navigationController.dismiss(animated: true) From 0c30f43eac74fc20ce447a80beb1acb36511a617 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 14:37:55 +0900 Subject: [PATCH 05/14] =?UTF-8?q?[FEAT]=20=EC=95=B1=20=EC=A2=85=EB=A3=8C?= =?UTF-8?q?=20=EC=8B=9C=20=EC=95=8C=EB=9E=8C=20=EC=8B=A4=ED=96=89=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=EC=97=90=20=EB=94=B0=EB=A5=B8=20=ED=91=B8?= =?UTF-8?q?=EC=8B=9C=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=B6=84=EA=B8=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EC=98=B5=EC=85=94=EB=84=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Atcha-iOS/App/SceneDelegate.swift | 20 ++++++++++++++++--- .../Presentation/Popup/AtchaPopupInfo.swift | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Atcha-iOS/App/SceneDelegate.swift b/Atcha-iOS/App/SceneDelegate.swift index 10804dd..6c61134 100644 --- a/Atcha-iOS/App/SceneDelegate.swift +++ b/Atcha-iOS/App/SceneDelegate.swift @@ -37,9 +37,23 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // This occurs shortly after the scene enters the background, or when its session is discarded. // Release any resources associated with this scene that can be re-created the next time the scene connects. // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). - if let _: LegInfo = UserDefaultsWrapper.shared.object(forKey: UserDefaultsWrapper.Key.legInfo.rawValue, of: LegInfo.self) { - AlarmManager.shared.sendBackgroundPush(title: "앗차를 다시 켜주세요", - body: "제 시간에 출발 시간을 알려드릴 수 있도록 앱을 다시 실행해 주세요.") + + let wrapper = UserDefaultsWrapper.shared + + if let _: LegInfo = wrapper.object(forKey: UserDefaultsWrapper.Key.legInfo.rawValue, of: LegInfo.self) { + let didFire = wrapper.bool(forKey: UserDefaultsWrapper.Key.departureAlarmDidFire.rawValue) ?? false + + if didFire { + AlarmManager.shared.sendBackgroundPush( + title: "앗차를 다시 켜주세요", + body: "목적지까지 안내할 수 있도록 앱을 다시 실행해 주세요" + ) + } else { + AlarmManager.shared.sendBackgroundPush( + title: "앗차를 다시 켜주세요", + body: "제 시간에 출발 시간을 알려드릴 수 있도록 앱을 다시 실행해 주세요." + ) + } } } diff --git a/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift b/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift index 50d350f..ab22fc1 100644 --- a/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift +++ b/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift @@ -23,7 +23,7 @@ enum AtcahPopuInfo { case .logout: return "로그아웃하시겠어요?" case .withdraw: return "탈퇴하시겠어요?" case .alarm: return "막차 알람을 종료할까요?" - case .re_register: return "기존 막차 알림을 종료하고\n선택한 알림으로 변경할까요?" + case .re_register: return "기존 막차 알림을 종료하고\n선택한 알람으로 변경할까요?" case .course : return "배차 간격이 긴 버스가 포함되어\n환승 대기 시간이 길어질 수 있어요.\n막차 알람을 등록할까요?" case .announeExit: return "" case .alarmTimeout: return "예정된 출발 시간이 지나\n알람이 자동으로 종료됐어요" From 88d0df0ace47b01249226853dc19a530f60fe702 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 15:16:38 +0900 Subject: [PATCH 06/14] =?UTF-8?q?[BUGFIX]=20=ED=95=98=EB=8B=A8=20=EB=B7=B0?= =?UTF-8?q?=20=EC=8B=9C=EA=B0=84=20=EC=A0=84=ED=99=98=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=AC=B4=ED=95=9C=20?= =?UTF-8?q?=EB=A3=A8=ED=94=84=20=ED=81=AC=EB=9E=98=EC=8B=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Location/MainViewController.swift | 84 +++++++++++++------ .../Presentation/Location/MainViewModel.swift | 6 +- .../View/LastTrainDepartBottomView.swift | 62 +++++++++----- 3 files changed, 102 insertions(+), 50 deletions(-) diff --git a/Atcha-iOS/Presentation/Location/MainViewController.swift b/Atcha-iOS/Presentation/Location/MainViewController.swift index 331d6c5..9410437 100644 --- a/Atcha-iOS/Presentation/Location/MainViewController.swift +++ b/Atcha-iOS/Presentation/Location/MainViewController.swift @@ -605,33 +605,69 @@ extension MainViewController { .store(in: &cancellables) } +// private func bindLegPathUpdates() { +// viewModel.$legInfo +// .receive(on: DispatchQueue.main) +// .combineLatest(viewModel.$bottomType) +// .sink { [weak self] info, bottomType in +// self?.commonAlarmSetupView() +// self?.addRouteLine(pathInfos: info?.pathInfo ?? []) +// +// switch bottomType { +// case .departure: +// self?.shouldCenterToCurrentLocationOnce = false +// self?.lastTrainDepartView.setupLegInfo(info: info) +// default: do {} +// } +// +// self?.setupBottomType(bottomType) +// } +// .store(in: &cancellables) +// +// viewModel.$bottomType +// .removeDuplicates() +// .receive(on: RunLoop.main) +// .sink { [weak self] type in +// self?.setupBottomType(type) +// } +// .store(in: &cancellables) +// +// viewModel.$departureTime +// .compactMap { $0 } +// .receive(on: RunLoop.main) +// .sink { [weak self] time in +// self?.lastTrainDepartView.refreshDepartureTime(departureStr: time) +// } +// .store(in: &cancellables) +// } + private func bindLegPathUpdates() { - viewModel.$legInfo - .receive(on: DispatchQueue.main) - .combineLatest(viewModel.$bottomType) - .sink { [weak self] info, bottomType in - self?.commonAlarmSetupView() - self?.addRouteLine(pathInfos: info?.pathInfo ?? []) - - switch bottomType { - case .departure: - self?.shouldCenterToCurrentLocationOnce = false - self?.lastTrainDepartView.setupLegInfo(info: info) - default: do {} - } - - self?.setupBottomType(bottomType) - } - .store(in: &cancellables) - - viewModel.$bottomType - .removeDuplicates() - .receive(on: RunLoop.main) - .sink { [weak self] type in - self?.setupBottomType(type) + // 1. 경로 정보, 2. 알람 실행 여부, 3. 현재 바텀 뷰 타입을 묶어서 감시 + Publishers.CombineLatest3( + viewModel.$legInfo, + UserDefaults.standard.publisher(for: \.departureAlarmDidFire).removeDuplicates(), + viewModel.$bottomType + ) + .receive(on: RunLoop.main) + .sink { [weak self] info, isFired, bottomType in + guard let self = self else { return } + + // 지도 경로 선 그리기 및 뷰 설정 + self.commonAlarmSetupView() + self.addRouteLine(pathInfos: info?.pathInfo ?? []) + + // 핵심: 알람 상태(isFired)를 setupLegInfo에 함께 전달 + if bottomType == .departure { + // LastTrainDepartBottomView의 데이터를 업데이트 + self.lastTrainDepartView.setupLegInfo(info: info, isFired: isFired) } - .store(in: &cancellables) + + // 바텀 뷰 노출/숨김 처리 + self.setupBottomType(bottomType) + } + .store(in: &cancellables) + // departureTime 바인딩 (서버에서 실시간 시간이 갱신될 때를 위해 유지) viewModel.$departureTime .compactMap { $0 } .receive(on: RunLoop.main) diff --git a/Atcha-iOS/Presentation/Location/MainViewModel.swift b/Atcha-iOS/Presentation/Location/MainViewModel.swift index 13cb8d2..9824ad9 100644 --- a/Atcha-iOS/Presentation/Location/MainViewModel.swift +++ b/Atcha-iOS/Presentation/Location/MainViewModel.swift @@ -164,9 +164,9 @@ final class MainViewModel: BaseViewModel{ addressDesc = address legInfo = info - let wrapper = UserDefaultsWrapper.shared - wrapper.set(address, forKey: UserDefaultsWrapper.Key.addressDesc.rawValue) - wrapper.set(info, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) +// let wrapper = UserDefaultsWrapper.shared +// wrapper.set(address, forKey: UserDefaultsWrapper.Key.addressDesc.rawValue) +// wrapper.set(info, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) setupLegInfo(info: info) } diff --git a/Atcha-iOS/Presentation/Location/View/LastTrainDepartBottomView.swift b/Atcha-iOS/Presentation/Location/View/LastTrainDepartBottomView.swift index 3a9bf77..79cd9a0 100644 --- a/Atcha-iOS/Presentation/Location/View/LastTrainDepartBottomView.swift +++ b/Atcha-iOS/Presentation/Location/View/LastTrainDepartBottomView.swift @@ -22,7 +22,7 @@ final class LastTrainDepartBottomView: UIView { private let titleView: UIView = UIView() private let trainTimeLabel: UILabel = UILabel() private let trainRigtImageView: UIImageView = UIImageView() -// private let reloadImageView: UIImageView = UIImageView() + // private let reloadImageView: UIImageView = UIImageView() private let timeView: UIView = UIView() private let hourTimeLabel: UILabel = UILabel() @@ -75,11 +75,11 @@ final class LastTrainDepartBottomView: UIView { trainRigtImageView.contentMode = .scaleAspectFit trainRigtImageView.tintColor = .gray500 -// reloadImageView.image = UIImage.refreshOutlined -// reloadImageView.contentMode = .scaleAspectFit -// reloadImageView.tintColor = .white -// reloadImageView.setContentHuggingPriority(.required, for: .horizontal) - + // reloadImageView.image = UIImage.refreshOutlined + // reloadImageView.contentMode = .scaleAspectFit + // reloadImageView.tintColor = .white + // reloadImageView.setContentHuggingPriority(.required, for: .horizontal) + hourTimeLabel.attributedText = AtchaFont.D2_EB_48("--", color: .white) minuteTimeLabel.attributedText = AtchaFont.D2_EB_48("--", color: .white) hourLabel.attributedText = AtchaFont.B1_R_17("시", color: .white) @@ -111,11 +111,11 @@ final class LastTrainDepartBottomView: UIView { make.size.equalTo(14) } -// reloadImageView.snp.makeConstraints { make in -// make.centerY.equalToSuperview() -// make.trailing.equalToSuperview() -// make.size.equalTo(28) -// } + // reloadImageView.snp.makeConstraints { make in + // make.centerY.equalToSuperview() + // make.trailing.equalToSuperview() + // make.size.equalTo(28) + // } timeView.snp.makeConstraints { make in make.leading.equalToSuperview().inset(16) @@ -161,8 +161,8 @@ final class LastTrainDepartBottomView: UIView { private func setupActions() { exitButton.addTarget(self, action: #selector(handleExitTapped), for: .touchUpInside) detailRoadMapButton.addTarget(self, action: #selector(handleDetailRoadTapped), for: .touchUpInside) -// reloadImageView.isUserInteractionEnabled = true -// reloadImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleReloadTapped))) + // reloadImageView.isUserInteractionEnabled = true + // reloadImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleReloadTapped))) timeView.isUserInteractionEnabled = true timeView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTimeTapped))) locationLabel.isUserInteractionEnabled = true @@ -180,17 +180,33 @@ final class LastTrainDepartBottomView: UIView { // MARK: Binding Leg Info extension LastTrainDepartBottomView { - func setupLegInfo(info: LegInfo?) { - guard let info, let departureStr = info.pathInfo.first?.departureDateTime else { return } - let formatter = DateFormatter() - formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" - formatter.locale = .current + func setupLegInfo(info: LegInfo?, isFired: Bool) { + guard let info = info, let timeText = info.trafficInfo.first?.timeText else { return } - if let _ = formatter.date(from: departureStr) { - if let (hour, minute) = departureStr.toHourMinute() { - hourTimeLabel.attributedText = AtchaFont.D2_EB_48(hour, color: .white) - minuteTimeLabel.attributedText = AtchaFont.D2_EB_48(minute, color: .white) - } + updateUIForAlarmStatus(isFired: isFired) + + let times = timeText.components(separatedBy: " ~ ").map { $0.trimmingCharacters(in: .whitespaces) } + + let targetTime: String + + if isFired { + targetTime = times.count > 1 ? times[1] : (times.first ?? "--:--") + } else { + targetTime = times.first ?? "--:--" + } + + let timeParts = targetTime.components(separatedBy: ":") + if timeParts.count == 2 { + let hour = timeParts[0] + let minute = timeParts[1] + + // 5. UI 적용 + hourTimeLabel.attributedText = AtchaFont.D2_EB_48(hour, color: .white) + minuteTimeLabel.attributedText = AtchaFont.D2_EB_48(minute, color: .white) + } else { + // 파싱 실패 시 기본값 + hourTimeLabel.attributedText = AtchaFont.D2_EB_48("--", color: .white) + minuteTimeLabel.attributedText = AtchaFont.D2_EB_48("--", color: .white) } } From 1e9b73aa017369156e172c9834092fd75b2aa226 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 15:57:51 +0900 Subject: [PATCH 07/14] =?UTF-8?q?[FEAT]=20=EB=8F=84=EC=B0=A9=2010=EB=B6=84?= =?UTF-8?q?=20=ED=9B=84=20=EC=9E=90=EB=8F=99=20=EC=A2=85=EB=A3=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Manager/Alarm/AlarmManager.swift | 50 +++++++++++++++++++ .../Manager/Location/HomeArrivalManager.swift | 3 ++ .../Presentation/Location/MainViewModel.swift | 8 +++ 3 files changed, 61 insertions(+) diff --git a/Atcha-iOS/Core/Manager/Alarm/AlarmManager.swift b/Atcha-iOS/Core/Manager/Alarm/AlarmManager.swift index 765aab0..991d08c 100644 --- a/Atcha-iOS/Core/Manager/Alarm/AlarmManager.swift +++ b/Atcha-iOS/Core/Manager/Alarm/AlarmManager.swift @@ -34,6 +34,7 @@ final class AlarmManager { private var isPreviewing = false private var hapticEngine: CHHapticEngine? private var autoStopWorkItem: DispatchWorkItem? + private var arrivalTimeoutWorkItem: DispatchWorkItem? // MARK: - Init private init() { @@ -454,6 +455,7 @@ extension AlarmManager { enum AlarmNotificationID { static let autoStopInfo = "atcha.alarm.autostop" static let tenMinutesBefore = "atcha.alarm.tenMinutesBefore" + static let scheduledArrivalTimeout = "atcha.arrival.timeout" } extension AlarmManager { @@ -640,3 +642,51 @@ extension AlarmManager { DispatchQueue.main.asyncAfter(deadline: .now() + 120.0, execute: workItem) } } + +extension AlarmManager { + + // 도착 10분 후 자동 종료 예약 함수 + func scheduleArrivalTimeout(at arrivalDate: Date) { + // 기존에 예약된 게 있다면 먼저 취소 + cancelArrivalTimeout() + + let timeoutDate = arrivalDate.addingTimeInterval(10 * 60) // 도착 시간 + 10분 + let timeInterval = timeoutDate.timeIntervalSinceNow + + // 만약 이미 시간이 지났다면 예약하지 않음 + guard timeInterval > 0 else { return } + + // 1. 백그라운드용 로컬 푸시 예약 (시스템이 정확한 시간에 띄워줌) + let content = UNMutableNotificationContent() + content.title = "막차 안내 종료" + content.body = "예정된 도착 시간이 지나 알람이 자동으로 종료됐어요" + content.sound = .default + + let trigger = UNTimeIntervalNotificationTrigger(timeInterval: timeInterval, repeats: false) + let request = UNNotificationRequest( + identifier: AlarmNotificationID.scheduledArrivalTimeout, + content: content, + trigger: trigger + ) + UNUserNotificationCenter.current().add(request, withCompletionHandler: nil) + + // 2. 포그라운드(앱이 켜져 있을 때) 로직 처리를 위한 WorkItem + let workItem = DispatchWorkItem { + print(" 도착 10분 초과: 자동 종료 실행") + // 메인 화면 등에 신호를 보내서 팝업을 띄우고 상태를 정리함 + NotificationCenter.default.post(name: NSNotification.Name("scheduledArrivalDidTimeout"), object: nil) + } + + // 변수를 따로 저장해두어야 나중에 취소(reset)가 가능합니다. + // (클래스 상단에 private var arrivalTimeoutWorkItem: DispatchWorkItem? 를 선언해두세요) + self.arrivalTimeoutWorkItem = workItem + DispatchQueue.main.asyncAfter(deadline: .now() + timeInterval, execute: workItem) + } + + // 예약 취소 함수 (집에 도착하거나 수동 종료했을 때 호출 필수!) + func cancelArrivalTimeout() { + arrivalTimeoutWorkItem?.cancel() + arrivalTimeoutWorkItem = nil + UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [AlarmNotificationID.scheduledArrivalTimeout]) + } +} diff --git a/Atcha-iOS/Core/Manager/Location/HomeArrivalManager.swift b/Atcha-iOS/Core/Manager/Location/HomeArrivalManager.swift index eda71c9..d90fe00 100644 --- a/Atcha-iOS/Core/Manager/Location/HomeArrivalManager.swift +++ b/Atcha-iOS/Core/Manager/Location/HomeArrivalManager.swift @@ -39,6 +39,8 @@ final class HomeArrivalManager { if distance <= 50 { isArrivalSignalSent = true + AlarmManager.shared.cancelArrivalTimeout() + AlarmManager.shared.sendImmediateLocalPush( title: "막차 안내 종료", body: "목적지 부근에 도착했어요", @@ -51,5 +53,6 @@ final class HomeArrivalManager { func reset() { isArrivalSignalSent = false + AlarmManager.shared.cancelArrivalTimeout() } } diff --git a/Atcha-iOS/Presentation/Location/MainViewModel.swift b/Atcha-iOS/Presentation/Location/MainViewModel.swift index 9824ad9..8ea7862 100644 --- a/Atcha-iOS/Presentation/Location/MainViewModel.swift +++ b/Atcha-iOS/Presentation/Location/MainViewModel.swift @@ -187,6 +187,8 @@ final class MainViewModel: BaseViewModel{ guard let arrivalDate = Calendar.current.date(byAdding: .minute, value: minutes, to: departureDate) else { return } + AlarmManager.shared.scheduleArrivalTimeout(at: arrivalDate) + print("departureDate : \(departureDate)") print("arrivalDate : \(arrivalDate)") let wrapper = UserDefaultsWrapper.shared @@ -378,6 +380,12 @@ final class MainViewModel: BaseViewModel{ // MARK: - 알림 취소 func alarmDelete() { + + stopAlarmTimer() + stopFinishAlarmTimer() + + AlarmManager.shared.cancelArrivalTimeout() + let wrapper = UserDefaultsWrapper.shared let savedLastRouteId: String? = wrapper.string( forKey: UserDefaultsWrapper.Key.lastRouteId.rawValue) From 945577b90ddd376cacbbd07d5b7e16092704dce1 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 16:14:39 +0900 Subject: [PATCH 08/14] =?UTF-8?q?[FEAT]=20=EB=8F=84=EC=B0=A9=2010=EB=B6=84?= =?UTF-8?q?=20=ED=9B=84=20=EC=A2=85=EB=A3=8C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=ED=8C=9D=EC=97=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Location/MainViewController.swift | 137 ++++++++++++------ .../Presentation/Popup/AtchaPopupInfo.swift | 7 +- .../Popup/AtchaPopupViewController.swift | 4 +- 3 files changed, 96 insertions(+), 52 deletions(-) diff --git a/Atcha-iOS/Presentation/Location/MainViewController.swift b/Atcha-iOS/Presentation/Location/MainViewController.swift index 9410437..d90da7c 100644 --- a/Atcha-iOS/Presentation/Location/MainViewController.swift +++ b/Atcha-iOS/Presentation/Location/MainViewController.swift @@ -311,6 +311,7 @@ extension MainViewController { bindPermissionAlert() bindAlarmFireStatus() observeArrival() + observeScheduledArrivalTimeout() observeAlarmTimeout() } @@ -474,7 +475,7 @@ extension MainViewController { popupVC?.dismiss(animated: false) self.viewModel.alarmDelete() - self.exitButtonTapped() + self.exitButtonTapped(showToast: true) amp_track(.alarm_force_stop) }, for: .touchUpInside) @@ -483,7 +484,7 @@ extension MainViewController { present(popupVC, animated: false) } - private func exitButtonTapped() { + private func exitButtonTapped(showToast: Bool) { // 가장 먼저 토스트 표시 상태로 변경 (이후 2.5초간 호출되는 모든 말풍선 로직 차단됨) isShowingToast = true @@ -518,14 +519,16 @@ extension MainViewController { UserDefaultsWrapper.shared.set(false, forKey: UserDefaultsWrapper.Key.alarmRegister.rawValue) - // 토스트 띄우고 토스트 사라진 후 고정형 말풍선 띄우기 (재방문 상태) - showToastAndThen(message: "알람이 종료되었어요", delay: 2.5) { [weak self] in - guard let self = self else { return } - self.showOrUpdatePersistentBalloon( - isFirstVisit: false, - isServiceRegion: self.latestIsServiceRegion ?? false, - fareStr: self.latestFareString - ) + if showToast { + // 토스트 띄우고 토스트 사라진 후 고정형 말풍선 띄우기 (재방문 상태) + showToastAndThen(message: "알람이 종료되었어요", delay: 2.5) { [weak self] in + guard let self = self else { return } + self.showOrUpdatePersistentBalloon( + isFirstVisit: false, + isServiceRegion: self.latestIsServiceRegion ?? false, + fareStr: self.latestFareString + ) + } } } @@ -605,42 +608,42 @@ extension MainViewController { .store(in: &cancellables) } -// private func bindLegPathUpdates() { -// viewModel.$legInfo -// .receive(on: DispatchQueue.main) -// .combineLatest(viewModel.$bottomType) -// .sink { [weak self] info, bottomType in -// self?.commonAlarmSetupView() -// self?.addRouteLine(pathInfos: info?.pathInfo ?? []) -// -// switch bottomType { -// case .departure: -// self?.shouldCenterToCurrentLocationOnce = false -// self?.lastTrainDepartView.setupLegInfo(info: info) -// default: do {} -// } -// -// self?.setupBottomType(bottomType) -// } -// .store(in: &cancellables) -// -// viewModel.$bottomType -// .removeDuplicates() -// .receive(on: RunLoop.main) -// .sink { [weak self] type in -// self?.setupBottomType(type) -// } -// .store(in: &cancellables) -// -// viewModel.$departureTime -// .compactMap { $0 } -// .receive(on: RunLoop.main) -// .sink { [weak self] time in -// self?.lastTrainDepartView.refreshDepartureTime(departureStr: time) -// } -// .store(in: &cancellables) -// } - + // private func bindLegPathUpdates() { + // viewModel.$legInfo + // .receive(on: DispatchQueue.main) + // .combineLatest(viewModel.$bottomType) + // .sink { [weak self] info, bottomType in + // self?.commonAlarmSetupView() + // self?.addRouteLine(pathInfos: info?.pathInfo ?? []) + // + // switch bottomType { + // case .departure: + // self?.shouldCenterToCurrentLocationOnce = false + // self?.lastTrainDepartView.setupLegInfo(info: info) + // default: do {} + // } + // + // self?.setupBottomType(bottomType) + // } + // .store(in: &cancellables) + // + // viewModel.$bottomType + // .removeDuplicates() + // .receive(on: RunLoop.main) + // .sink { [weak self] type in + // self?.setupBottomType(type) + // } + // .store(in: &cancellables) + // + // viewModel.$departureTime + // .compactMap { $0 } + // .receive(on: RunLoop.main) + // .sink { [weak self] time in + // self?.lastTrainDepartView.refreshDepartureTime(departureStr: time) + // } + // .store(in: &cancellables) + // } + private func bindLegPathUpdates() { // 1. 경로 정보, 2. 알람 실행 여부, 3. 현재 바텀 뷰 타입을 묶어서 감시 Publishers.CombineLatest3( @@ -1103,7 +1106,7 @@ extension MainViewController { self.navigationController?.popToRootViewController(animated: true) self.viewModel.alarmDelete() - self.exitButtonTapped() + self.exitButtonTapped(showToast: false) amp_track(.alarm_arrive_stop) @@ -1139,7 +1142,7 @@ extension MainViewController { self.navigationController?.popToRootViewController(animated: true) self.viewModel.alarmDelete() - self.exitButtonTapped() + self.exitButtonTapped(showToast: false) amp_track(.alarm_timeout_stop) @@ -1156,6 +1159,44 @@ extension MainViewController { } .store(in: &cancellables) } + + + private func observeScheduledArrivalTimeout() { + NotificationCenter.default.publisher(for: NSNotification.Name("scheduledArrivalDidTimeout")) + .receive(on: RunLoop.main) + .sink { [weak self] _ in + guard let self = self else { return } + + // 10분 지났을 때도 상세화면에서 메인으로 강제 복귀! + self.navigationController?.popToRootViewController(animated: true) + + self.viewModel.alarmDelete() + self.exitButtonTapped(showToast: false) + + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + self.showScheduledArrivalPopup() + } + } + .store(in: &cancellables) + } + + private func showScheduledArrivalPopup() { + if presentedViewController is AtchaPopupViewController { return } + + let popupVM = AtchaPopupViewModel(info: .scheduledArrive) + let popupVC = AtchaPopupViewController(viewModel: popupVM) + + popupVC.modalPresentationStyle = .overFullScreen + popupVC.modalTransitionStyle = .crossDissolve + + popupVC.confirmButton.addAction(UIAction { [weak popupVC] _ in + popupVC?.dismiss(animated: false) + HomeArrivalManager.shared.reset() + AlarmManager.shared.cancelArrivalTimeout() + }, for: .touchUpInside) + + self.present(popupVC, animated: false) + } } // MARK: - 말풍선 제어 코어 로직 diff --git a/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift b/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift index ab22fc1..14f80ec 100644 --- a/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift +++ b/Atcha-iOS/Presentation/Popup/AtchaPopupInfo.swift @@ -16,6 +16,7 @@ enum AtcahPopuInfo { case announeExit case alarmTimeout case arrive + case scheduledArrive case serverError var title: String { @@ -28,6 +29,7 @@ enum AtcahPopuInfo { case .announeExit: return "" case .alarmTimeout: return "예정된 출발 시간이 지나\n알람이 자동으로 종료됐어요" case .arrive: return "목적지 부근에 도착해\n안내를 종료합니다" + case .scheduledArrive: return "예정된 도착 시간이 지나\n알람이 자동으로 종료됐어요" case .serverError: return "잠시 후 다시 시도해주세요\n앗차팀에서 확인 및 대응 중입니다" } } @@ -42,6 +44,7 @@ enum AtcahPopuInfo { case .announeExit: return "확인" case .alarmTimeout: return "닫기" case .arrive: return "확인" + case .scheduledArrive: return "닫기" case .serverError: return "확인" } } @@ -49,14 +52,14 @@ enum AtcahPopuInfo { var confrimBackgroundColor: UIColor { switch self { case .alarm, .re_register, .course, .arrive: return .main - case .alarmTimeout, .serverError: return .gray910 + case .alarmTimeout, .serverError, .scheduledArrive: return .gray910 default: return .white } } var confrimForegroundColor: UIColor { switch self { - case .alarmTimeout, .serverError: return .white + case .alarmTimeout, .serverError, .scheduledArrive: return .white default: return .black } } diff --git a/Atcha-iOS/Presentation/Popup/AtchaPopupViewController.swift b/Atcha-iOS/Presentation/Popup/AtchaPopupViewController.swift index cb16df7..ed0b20d 100644 --- a/Atcha-iOS/Presentation/Popup/AtchaPopupViewController.swift +++ b/Atcha-iOS/Presentation/Popup/AtchaPopupViewController.swift @@ -80,7 +80,7 @@ final class AtchaPopupViewController: BaseViewController { confirmButton.setAttributedTitle(confirmAttr, for: .normal) confirmButton.backgroundColor = info.confrimBackgroundColor - if info != .alarmTimeout || info != .arrive || info != .serverError { + if info != .alarmTimeout || info != .arrive || info != .serverError || info != .scheduledArrive { let cancelAttr = AtchaFont.B5_SB_14(info.cancelTitle, color: info.cancelForegroundColor) cancelButton.setAttributedTitle(cancelAttr, for: .normal) cancelButton.backgroundColor = info.cancelBackgroundColor @@ -93,7 +93,7 @@ final class AtchaPopupViewController: BaseViewController { $0.removeFromSuperview() } - if info == .alarmTimeout || info == .arrive || info == .serverError { + if info == .alarmTimeout || info == .arrive || info == .serverError || info == .scheduledArrive { buttonStackView.addArrangedSubview(confirmButton) } else { buttonStackView.addArrangedSubview(cancelButton) From 491ce36156e89a4a1e3e9ea0bf08b23ba97d51ef Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 16:32:53 +0900 Subject: [PATCH 09/14] =?UTF-8?q?[FEAT]=20=EC=95=B1=20=EC=9E=AC=EC=8B=A4?= =?UTF-8?q?=ED=96=89=20=EC=8B=9C=20=EC=95=8C=EB=9E=8C=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=20=EB=B3=B5=EA=B5=AC=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Location/MainViewModel.swift | 105 +++++++++++------- 1 file changed, 63 insertions(+), 42 deletions(-) diff --git a/Atcha-iOS/Presentation/Location/MainViewModel.swift b/Atcha-iOS/Presentation/Location/MainViewModel.swift index 8ea7862..1982b9a 100644 --- a/Atcha-iOS/Presentation/Location/MainViewModel.swift +++ b/Atcha-iOS/Presentation/Location/MainViewModel.swift @@ -13,7 +13,6 @@ import TMapSDK final class MainViewModel: BaseViewModel{ private var alarmTimerCancellable: AnyCancellable? - private var alarmFinishCancellable: AnyCancellable? private var alarmTimeoutCancellable: AnyCancellable? private var alarmObserver: NSObjectProtocol? private var refreshUpdateToken: NSObjectProtocol? @@ -79,6 +78,7 @@ final class MainViewModel: BaseViewModel{ super.init() observeGlobalRefresh() + restoreAlarmState() self.bind() } @@ -112,16 +112,16 @@ final class MainViewModel: BaseViewModel{ .store(in: &cancellables) UserDefaultsWrapper.shared.legInfoPublisher - .compactMap { $0 } - .receive(on: RunLoop.main) - .sink { [weak self] newInfo in - guard let self = self else { return } - - if self.legInfo != newInfo { - self.drawRoute(address: self.addressDesc, info: newInfo) - } + .compactMap { $0 } + .receive(on: RunLoop.main) + .sink { [weak self] newInfo in + guard let self = self else { return } + + if self.legInfo != newInfo { + self.drawRoute(address: self.addressDesc, info: newInfo) } - .store(in: &cancellables) + } + .store(in: &cancellables) } private func updateAddressOnly(for location: CLLocationCoordinate2D) async { @@ -164,9 +164,9 @@ final class MainViewModel: BaseViewModel{ addressDesc = address legInfo = info -// let wrapper = UserDefaultsWrapper.shared -// wrapper.set(address, forKey: UserDefaultsWrapper.Key.addressDesc.rawValue) -// wrapper.set(info, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) + // let wrapper = UserDefaultsWrapper.shared + // wrapper.set(address, forKey: UserDefaultsWrapper.Key.addressDesc.rawValue) + // wrapper.set(info, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) setupLegInfo(info: info) } @@ -349,7 +349,6 @@ final class MainViewModel: BaseViewModel{ wrapper.set(body, forKey: UserDefaultsWrapper.Key.departureTime.rawValue) fetchDetailRoute() - stopFinishAlarmTimer() startAlarmTimer() checkAlarmTime() @@ -382,7 +381,6 @@ final class MainViewModel: BaseViewModel{ func alarmDelete() { stopAlarmTimer() - stopFinishAlarmTimer() AlarmManager.shared.cancelArrivalTimeout() @@ -505,39 +503,12 @@ extension MainViewModel { .sink { [weak self] _ in self?.checkAlarmTime() } - - alarmFinishCancellable = Timer - .publish(every: 60.0, on: .main, in: .common) - .autoconnect() - .sink { [weak self] _ in - guard let self else { return } - if let arrivalTime = UserDefaultsWrapper.shared.object( - forKey: UserDefaultsWrapper.Key.arrivalTime.rawValue, - of: Date.self - ) { - let now = Date() - let thirtyMinutesLater = arrivalTime.addingTimeInterval(30 * 60) // 30분 후 - - print("departure Time : \(arrivalTime)") - print("30분 후 시각 : \(thirtyMinutesLater)") - - if now >= thirtyMinutesLater { - stopFinishAlarmTimer() - bottomType = .search - } - } - } } private func stopAlarmTimer() { alarmTimerCancellable?.cancel() alarmTimerCancellable = nil } - - func stopFinishAlarmTimer() { - alarmFinishCancellable?.cancel() - alarmFinishCancellable = nil - } } @@ -694,3 +665,53 @@ extension MainViewModel { } } } + +extension MainViewModel { + func restoreAlarmState() { + let wrapper = UserDefaultsWrapper.shared + + // 1. 알람이 등록되어 있는지 확인 + guard wrapper.bool(forKey: UserDefaultsWrapper.Key.alarmRegister.rawValue) == true else { return } + + // 2. 데이터 가져오기 + guard let departureStr = wrapper.string(forKey: UserDefaultsWrapper.Key.departureTime.rawValue), + let arrivalDate = wrapper.object(forKey: UserDefaultsWrapper.Key.arrivalTime.rawValue, of: Date.self) else { return } + + let formatter = DateFormatter() + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" + formatter.timeZone = TimeZone(identifier: "Asia/Seoul") + + guard let departureDate = formatter.date(from: departureStr) else { return } + + let now = Date() + let timeoutDate = arrivalDate.addingTimeInterval(10 * 60) + + // --- 분기 처리 --- + + if now < departureDate { + // [Case 1] 아직 출발 전 + startAlarmTimer() + + } else if now >= departureDate && now < timeoutDate { + // [Case 2] 이동 중 (핵심!) + + // 중요: 이미 알람이 울린 것으로 간주하여 플래그 세팅 (경로 스냅핑 활성화) + wrapper.set(true, forKey: UserDefaultsWrapper.Key.departureAlarmDidFire.rawValue) + AlarmManager.shared.scheduleArrivalTimeout(at: arrivalDate) + // 소리 알람(AlarmManager.startAlarm)은 호출하지 않음! + self.showLockView = false // 잠금화면 보이지 않음 + self.bottomType = .departure // 하단 바를 '안내 중' 상태로 변경 + + + if let current = self.currentLocation { + HomeArrivalManager.shared.checkHomeArrival(currentCoord: current) + } + + } else if now >= timeoutDate { + // [Case 3] 이미 한참 지남 + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + NotificationCenter.default.post(name: NSNotification.Name("scheduledArrivalDidTimeout"), object: nil) + } + } + } +} From f9af591a5165b7cdc61ec4fc262c9bedc2aaa47b Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 16:45:08 +0900 Subject: [PATCH 10/14] =?UTF-8?q?[FEAT]=20=ED=8A=B9=EC=A0=95=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EB=B0=9C=EC=83=9D=20=EC=8B=9C?= =?UTF-8?q?=20=EC=8B=A4=EC=8B=9C=EA=B0=84=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=ED=8F=B4=EB=A7=81=20=EC=A4=91=EB=8B=A8=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Atcha-iOS/Core/Network/API/APIError.swift | 2 +- Atcha-iOS/Core/Network/API/APIServiceImpl.swift | 7 ++++--- .../DetailRoute/DetailRouteViewModel.swift | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Atcha-iOS/Core/Network/API/APIError.swift b/Atcha-iOS/Core/Network/API/APIError.swift index fa96460..15edab7 100644 --- a/Atcha-iOS/Core/Network/API/APIError.swift +++ b/Atcha-iOS/Core/Network/API/APIError.swift @@ -10,7 +10,7 @@ import Foundation enum APIError: Error { case invalidURL case decodingError - case serverError(statusCode: Int) + case serverError(statusCode: Int, responseCode: String? = nil) case unknown(error: Error) case noData } diff --git a/Atcha-iOS/Core/Network/API/APIServiceImpl.swift b/Atcha-iOS/Core/Network/API/APIServiceImpl.swift index 844d749..0a63399 100644 --- a/Atcha-iOS/Core/Network/API/APIServiceImpl.swift +++ b/Atcha-iOS/Core/Network/API/APIServiceImpl.swift @@ -44,7 +44,7 @@ final class APIServiceImpl: APIService, @unchecked Sendable { } else { self.handleFailure(response: response, endpoint: endpoint, continuation: continuation) } - case .failure(let error): + case .failure(_): self.handleFailure(response: response, endpoint: endpoint, continuation: continuation) } } @@ -92,7 +92,7 @@ extension APIServiceImpl { self.handleFailure(response: response, endpoint: endpoint, requestBody: body.toDictionary(), continuation: continuation) } - case .failure(let error): + case .failure(_): self.handleFailure(response: response, endpoint: endpoint, requestBody: body.toDictionary(), continuation: continuation) } } @@ -134,7 +134,8 @@ extension APIServiceImpl { requestParameters: endpoint.parameters // GET query params ) - let apiError = APIError.serverError(statusCode: statusCode) + let apiError = APIError.serverError(statusCode: statusCode, responseCode: responseCode) + NotificationCenter.default.post(name: .apiErrorOccurred, object: apiError) continuation.resume(throwing: apiError) } diff --git a/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift b/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift index 3e97039..14a9a35 100644 --- a/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift +++ b/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift @@ -481,3 +481,20 @@ extension DetailRouteViewModel { return best } } + + +extension DetailRouteViewModel { + private func checkAndStopPolling(error: Error) -> Bool { + if let apiError = error as? APIError { + if case .serverError(_, let code) = apiError { + let stopCodes = ["URT_001", "LRT_001", "LRT_003"] + + if let code = code, stopCodes.contains(code) { + self.stopPolling() + return true + } + } + } + return false + } +} From bbe14006b839d219b0c33e0965444d26d98242b5 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 17:32:56 +0900 Subject: [PATCH 11/14] =?UTF-8?q?[BUGFIX]=20=EC=9C=84=EC=B9=98=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EA=B0=80=EA=B3=B5=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B5=9C=EC=A0=81=ED=99=94=20=EB=B0=8F=20=ED=8A=95=EA=B9=80=20?= =?UTF-8?q?=ED=98=84=EC=83=81=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/BaseViewController.swift | 2 +- .../DetailRoute/DetailRouteViewModel.swift | 9 +++- .../Location/MainViewController.swift | 1 - .../Presentation/Location/MainViewModel.swift | 53 ++++++++++--------- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Atcha-iOS/Presentation/Common/BaseViewController.swift b/Atcha-iOS/Presentation/Common/BaseViewController.swift index 9b1c764..b412085 100644 --- a/Atcha-iOS/Presentation/Common/BaseViewController.swift +++ b/Atcha-iOS/Presentation/Common/BaseViewController.swift @@ -230,7 +230,7 @@ class BaseViewController: UIViewController { guard let apiError = notification.object as? APIError else { return } // 2. 에러 케이스와 상태 코드 추출 (APIError가 statusCode를 가지고 있다고 가정) - if case .serverError(let statusCode) = apiError { + if case .serverError(let statusCode, _) = apiError { // 3. 500번대 에러인 경우에만 팝업 노출 if (500...599).contains(statusCode) && !ErrorState.isShowing500Error { diff --git a/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift b/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift index 14a9a35..6f53871 100644 --- a/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift +++ b/Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift @@ -58,6 +58,9 @@ final class DetailRouteViewModel: BaseViewModel { private var didSendInitialLocation = false private var consecutiveValidCount = 0 + + private var isCalculatingProximity = false + func forceLocationSnap() { self.didSendInitialLocation = false self.lastValidTime = nil @@ -166,6 +169,7 @@ final class DetailRouteViewModel: BaseViewModel { @MainActor func refreshAllRealTimeData() async { + guard !isRefreshing else { return } guard !busRoutes.isEmpty || !subwayRoutes.isEmpty else { return } isRefreshing = true // 애니메이션 시작 신호 @@ -401,7 +405,9 @@ extension DetailRouteViewModel { extension DetailRouteViewModel { /// 현재 좌표를 기준으로 가장 가까운 경로를 찾아 nearLegIDs를 업데이트합니다. func calculateProximity(coord: CLLocationCoordinate2D?) { - guard let coord = coord else { return } + guard let coord = coord, !isCalculatingProximity else { return } + + isCalculatingProximity = true let threshold: CLLocationDistance = 150 let polylines = self.legPolylineById @@ -442,6 +448,7 @@ extension DetailRouteViewModel { DispatchQueue.main.async { self.nearLegIDs = picked self.departedLegIDs = departed + self.isCalculatingProximity = false } } } diff --git a/Atcha-iOS/Presentation/Location/MainViewController.swift b/Atcha-iOS/Presentation/Location/MainViewController.swift index d90da7c..c39c7e0 100644 --- a/Atcha-iOS/Presentation/Location/MainViewController.swift +++ b/Atcha-iOS/Presentation/Location/MainViewController.swift @@ -714,7 +714,6 @@ extension MainViewController { } case .search: - viewModel.stopFinishAlarmTimer() lastTrainSearchView.isHidden = false flagImageView.isHidden = false diff --git a/Atcha-iOS/Presentation/Location/MainViewModel.swift b/Atcha-iOS/Presentation/Location/MainViewModel.swift index 1982b9a..72c6da4 100644 --- a/Atcha-iOS/Presentation/Location/MainViewModel.swift +++ b/Atcha-iOS/Presentation/Location/MainViewModel.swift @@ -59,6 +59,14 @@ final class MainViewModel: BaseViewModel{ private var lastValidTime: Date? = nil private var consecutiveValidCount = 0 + private static let isoDateFormatter: DateFormatter = { + let formatter = DateFormatter() + formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" + formatter.locale = Locale(identifier: "ko_KR") // 혹은 .current + return formatter + }() + private var cachedPathCoordinates: [CLLocationCoordinate2D] = [] + init(authorizationUseCase: RequestLocationAuthorizationUseCase, streamUseCase: ObserveLocationStreamUseCase, fetchTaxiFareUseCase: FetchTaxiFareUseCase, @@ -157,43 +165,42 @@ final class MainViewModel: BaseViewModel{ await MainActor.run { self.taxiFare = fare } } catch { print("택시비 조회 실패: \(error)") } } - + func drawRoute(address: String?, info: LegInfo?) { guard let address, let info else { return } addressDesc = address legInfo = info - // let wrapper = UserDefaultsWrapper.shared - // wrapper.set(address, forKey: UserDefaultsWrapper.Key.addressDesc.rawValue) - // wrapper.set(info, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) + let wrapper = UserDefaultsWrapper.shared + wrapper.set(address, forKey: UserDefaultsWrapper.Key.addressDesc.rawValue) + wrapper.set(info, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) setupLegInfo(info: info) } private func setupLegInfo(info: LegInfo?) { - let routeId = info?.pathInfo.first?.routeId - - guard let info, let departureStr = info.pathInfo.first?.departureDateTime, + guard let info, + let departureStr = info.pathInfo.first?.departureDateTime, let totalTime = info.trafficInfo.first?.totalTime else { return } self.departureStr = departureStr - let formatter = DateFormatter() - formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" - formatter.locale = .current + UserDefaultsWrapper.shared.set(info, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) - guard let departureDate = formatter.date(from: departureStr) else { return } + guard let departureDate = Self.isoDateFormatter.date(from: departureStr) else { return } let minutes = parseTotalTimeToMinutes(totalTime) - guard let arrivalDate = Calendar.current.date(byAdding: .minute, value: minutes, to: departureDate) else { return } - AlarmManager.shared.scheduleArrivalTimeout(at: arrivalDate) - - print("departureDate : \(departureDate)") - print("arrivalDate : \(arrivalDate)") let wrapper = UserDefaultsWrapper.shared - wrapper.set(departureStr, forKey: UserDefaultsWrapper.Key.departureTime.rawValue) - wrapper.set(arrivalDate, forKey: UserDefaultsWrapper.Key.arrivalTime.rawValue) + let savedArrival = wrapper.object(forKey: UserDefaultsWrapper.Key.arrivalTime.rawValue, of: Date.self) + + + if savedArrival != arrivalDate { + AlarmManager.shared.scheduleArrivalTimeout(at: arrivalDate) + wrapper.set(departureStr, forKey: UserDefaultsWrapper.Key.departureTime.rawValue) + wrapper.set(arrivalDate, forKey: UserDefaultsWrapper.Key.arrivalTime.rawValue) + self.cachedPathCoordinates = info.pathInfo.flatMap { convertShapeToCoords($0.passShape ?? "") } + } } private func parseTotalTimeToMinutes(_ time: String) -> Int { @@ -286,11 +293,8 @@ final class MainViewModel: BaseViewModel{ // 알람이 울린 후(`isAlarmFired`)에만 경로 스냅 적용 let isAlarmFired = UserDefaultsWrapper.shared.bool(forKey: UserDefaultsWrapper.Key.departureAlarmDidFire.rawValue) ?? false - if isAlarmFired, let path = self.legInfo?.pathInfo { - let allCoords = path.flatMap { convertShapeToCoords($0.passShape ?? "") } - if !allCoords.isEmpty { - finalCoord = smoother.snap(current: smoothedCoord, polyline: allCoords) - } + if isAlarmFired && !self.cachedPathCoordinates.isEmpty { + finalCoord = smoother.snap(current: smoothedCoord, polyline: self.cachedPathCoordinates) } let capturedCoord = finalCoord @@ -370,7 +374,7 @@ final class MainViewModel: BaseViewModel{ trafficInfo: trafficInfo, busInfo: busInfo) wrapper.set(legInfo, forKey: UserDefaultsWrapper.Key.legInfo.rawValue) - drawRoute(address: addressDesc, info: legInfo) + self.drawRoute(address: self.addressDesc, info: legInfo) } catch { print("routeId 조회 대실패 ㅠㅠ!!") } @@ -540,7 +544,6 @@ extension MainViewModel { routeHandler?(.myPage) case .detailRoute: - fetchDetailRoute() // 이걸 통신을 할까 말까 let wrapper = UserDefaultsWrapper.shared guard let info = wrapper.object(forKey: UserDefaultsWrapper.Key.legInfo.rawValue, of: LegInfo.self), From 2dc5b25c427c9786d7e29163605fdb11cecc1183 Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 17:38:18 +0900 Subject: [PATCH 12/14] =?UTF-8?q?[FEAT]=20=EC=95=B1=20=EC=9E=AC=EC=8B=A4?= =?UTF-8?q?=ED=96=89=20=EC=8B=9C=20=EA=B2=BD=EB=A1=9C=20=EC=A2=8C=ED=91=9C?= =?UTF-8?q?=20=EC=BA=90=EC=8B=9C=20=EB=B3=B5=EA=B5=AC=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Atcha-iOS/Presentation/Location/MainViewModel.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Atcha-iOS/Presentation/Location/MainViewModel.swift b/Atcha-iOS/Presentation/Location/MainViewModel.swift index 72c6da4..4dd0f46 100644 --- a/Atcha-iOS/Presentation/Location/MainViewModel.swift +++ b/Atcha-iOS/Presentation/Location/MainViewModel.swift @@ -165,7 +165,7 @@ final class MainViewModel: BaseViewModel{ await MainActor.run { self.taxiFare = fare } } catch { print("택시비 조회 실패: \(error)") } } - + func drawRoute(address: String?, info: LegInfo?) { guard let address, let info else { return } @@ -701,7 +701,14 @@ extension MainViewModel { // 중요: 이미 알람이 울린 것으로 간주하여 플래그 세팅 (경로 스냅핑 활성화) wrapper.set(true, forKey: UserDefaultsWrapper.Key.departureAlarmDidFire.rawValue) AlarmManager.shared.scheduleArrivalTimeout(at: arrivalDate) - // 소리 알람(AlarmManager.startAlarm)은 호출하지 않음! + + if let savedLegInfo = wrapper.object(forKey: UserDefaultsWrapper.Key.legInfo.rawValue, of: LegInfo.self) { + self.legInfo = savedLegInfo // Published 변수 복구 + + let coords = savedLegInfo.pathInfo.flatMap { convertShapeToCoords($0.passShape ?? "") } + self.cachedPathCoordinates = coords + } + self.showLockView = false // 잠금화면 보이지 않음 self.bottomType = .departure // 하단 바를 '안내 중' 상태로 변경 From fed4404cf1e05e548c76b4367726559a1a1d3a3a Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Fri, 20 Mar 2026 22:56:20 +0900 Subject: [PATCH 13/14] =?UTF-8?q?[BUGFIX]=20=ED=86=A0=ED=81=B0=20=EC=9E=AC?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=EC=8B=9C=20=EC=9D=B8=ED=84=B0=EC=85=89?= =?UTF-8?q?=ED=84=B0=20=ED=97=A4=EB=8D=94=20=EA=B0=84=EC=84=AD=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Atcha-iOS/Core/Network/Token/TokenInterceptor.swift | 3 ++- Atcha-iOS/Presentation/Lock/LockViewController.swift | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Atcha-iOS/Core/Network/Token/TokenInterceptor.swift b/Atcha-iOS/Core/Network/Token/TokenInterceptor.swift index ce6be6d..4bdab1b 100644 --- a/Atcha-iOS/Core/Network/Token/TokenInterceptor.swift +++ b/Atcha-iOS/Core/Network/Token/TokenInterceptor.swift @@ -33,7 +33,8 @@ final class TokenInterceptor: RequestInterceptor, @unchecked Sendable { "/auth/login", "/app/version", "/locations/is-service-region", - "/api/locations/rgeo" + "/api/locations/rgeo", + "/auth/reissue" ] if publicPaths.contains(where: { path.hasSuffix($0) }) { diff --git a/Atcha-iOS/Presentation/Lock/LockViewController.swift b/Atcha-iOS/Presentation/Lock/LockViewController.swift index 8198201..d90fbce 100644 --- a/Atcha-iOS/Presentation/Lock/LockViewController.swift +++ b/Atcha-iOS/Presentation/Lock/LockViewController.swift @@ -168,6 +168,11 @@ final class LockViewController: BaseViewController { amp_track(.later_course_click) viewModel.routerHandler?(.courseSearch(startLat: lat, startLon: lon, startAddress: address, context: .afterReigster)) + + UserDefaultsWrapper.shared.set( + true, + forKey: UserDefaultsWrapper.Key.departureAlarmDidFire.rawValue + ) } private func observeAlarmTimeout() { From fd006b7b8ac79d4bcab3842ab66fe696326e6c6a Mon Sep 17 00:00:00 2001 From: JaeWoong Eum Date: Sat, 21 Mar 2026 00:02:38 +0900 Subject: [PATCH 14/14] =?UTF-8?q?[BUGFIX]=20=EB=94=94=EC=8A=A4=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=97=90=EB=9F=AC=20=EB=A1=9C=EA=B7=B8=EC=97=90=20?= =?UTF-8?q?=EC=8B=A4=EC=A0=9C=20=EC=A0=84=EC=86=A1=EB=90=9C=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=ED=86=A0=ED=81=B0=20=EB=85=B8=EC=B6=9C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Discord/DiscordWebhookManager.swift | 21 +++++++++---------- .../Core/Network/API/APIServiceImpl.swift | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Atcha-iOS/Core/Manager/Discord/DiscordWebhookManager.swift b/Atcha-iOS/Core/Manager/Discord/DiscordWebhookManager.swift index ce9f112..db6aa85 100644 --- a/Atcha-iOS/Core/Manager/Discord/DiscordWebhookManager.swift +++ b/Atcha-iOS/Core/Manager/Discord/DiscordWebhookManager.swift @@ -10,9 +10,9 @@ import Foundation final class DiscordWebhookManager { static let shared = DiscordWebhookManager() private init() {} - + private let webhookURLString = "https://discord.com/api/webhooks/1483870710018474066/qyzNBI1Bwr7J5tQDrPx2-mOcej_9yLSOk5Bmlmza2D-4nSWqvWgcMd4CZDziG4vkpKrm" - + func sendErrorLog( statusCode: Int, method: String, @@ -24,13 +24,12 @@ final class DiscordWebhookManager { requestParameters: [String: Any]? = nil ) { guard let url = URL(string: webhookURLString) else { return } - + // Authorization 토큰 앞 30자만 노출 let headersText = requestHeaders.map { key, value in - let safeValue = key == "Authorization" ? String(value.prefix(30)) + "..." : value - return "\(key): \(safeValue)" + return "\(key): \(value)" }.joined(separator: "\n") - + // body JSON 변환 let bodyText: String if let body = requestBody, @@ -40,7 +39,7 @@ final class DiscordWebhookManager { } else { bodyText = "None" } - + let paramsText: String if let params = requestParameters, let data = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted), @@ -49,7 +48,7 @@ final class DiscordWebhookManager { } else { paramsText = "None" } - + let payload: [String: Any] = [ "content": "🚨 [Atcha-iOS] API 에러 발생!", "embeds": [[ @@ -62,18 +61,18 @@ final class DiscordWebhookManager { ["name": "App Version", "value": AppInfoProvider.currentVersion, "inline": true], ["name": "Error Message", "value": message, "inline": false], ["name": "Request Headers", "value": "```\n\(headersText)\n```", "inline": false], - ["name": "Request Parameters", "value": paramsText, "inline": false], + ["name": "Request Parameters", "value": paramsText, "inline": false], ["name": "Request Body", "value": bodyText, "inline": false] ], "footer": ["text": "발생 시각: \(Date().kstString)"] ]] ] - + var request = URLRequest(url: url) request.httpMethod = "POST" request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.httpBody = try? JSONSerialization.data(withJSONObject: payload) - + URLSession.shared.dataTask(with: request).resume() } } diff --git a/Atcha-iOS/Core/Network/API/APIServiceImpl.swift b/Atcha-iOS/Core/Network/API/APIServiceImpl.swift index 0a63399..44d1005 100644 --- a/Atcha-iOS/Core/Network/API/APIServiceImpl.swift +++ b/Atcha-iOS/Core/Network/API/APIServiceImpl.swift @@ -110,7 +110,7 @@ extension APIServiceImpl { let statusCode = response.response?.statusCode ?? -1 let method = endpoint.method.rawValue.uppercased() let path = endpoint.path - let requestHeaders = endpoint.headers?.dictionary ?? [:] + let actualSentHeaders = response.request?.allHTTPHeaderFields ?? [:] var responseCode = "UNKNOWN" var serverMessage = "(메시지 없음)" @@ -129,7 +129,7 @@ extension APIServiceImpl { path: serverPath, responseCode: responseCode, message: serverMessage, - requestHeaders: requestHeaders, + requestHeaders: actualSentHeaders, requestBody: requestBody, // POST/PUT body requestParameters: endpoint.parameters // GET query params )