diff --git a/mirroringBooth/mirroringBooth/Device/Camera/Browser/WatchConnectionManager+iOS.swift b/mirroringBooth/mirroringBooth/Device/Camera/Browser/WatchConnectionManager+iOS.swift index d4b2b45e..d1a665c5 100644 --- a/mirroringBooth/mirroringBooth/Device/Camera/Browser/WatchConnectionManager+iOS.swift +++ b/mirroringBooth/mirroringBooth/Device/Camera/Browser/WatchConnectionManager+iOS.swift @@ -12,6 +12,7 @@ import WatchConnectivity final class WatchConnectionManager: NSObject { private enum ActionValue: String { + case pushState case capture case connect case prepare @@ -198,6 +199,12 @@ extension WatchConnectionManager: WCSessionDelegate { if let error: Error = error { self.logger.error("WCSession 활성화 실패: 오류=\(error.localizedDescription)") } else { + session.sendMessage( + [MessageKey.action.rawValue: ActionValue.pushState.rawValue], + replyHandler: nil + ) { error in + self.logger.warning("WCSession handshake 실패: \(error)") + } self.logger.info("WCSession 활성화 성공") } } diff --git a/mirroringBooth/mirroringBooth/Device/Remote/AppleWatch/WatchConnectionManger+watchOS.swift b/mirroringBooth/mirroringBooth/Device/Remote/AppleWatch/WatchConnectionManger+watchOS.swift index cec04f06..8b41b65a 100644 --- a/mirroringBooth/mirroringBooth/Device/Remote/AppleWatch/WatchConnectionManger+watchOS.swift +++ b/mirroringBooth/mirroringBooth/Device/Remote/AppleWatch/WatchConnectionManger+watchOS.swift @@ -12,6 +12,7 @@ import WatchConnectivity final class WatchConnectionManager: NSObject { private enum ActionValue: String { + case pushState case capture case connect case prepare @@ -36,6 +37,7 @@ final class WatchConnectionManager: NSObject { private let session: WCSession? private let logger = Logger.watchConnectionManager private var lastAppState: AppStateValue = .terminated + private var watchState: AppStateValue = .inactive var onReachableChanged: ((Bool) -> Void)? @@ -112,7 +114,8 @@ final class WatchConnectionManager: NSObject { try session.updateApplicationContext([MessageKey.appState.rawValue: state.rawValue]) self.logger.info("Watch 앱 상태 푸시: \(state.rawValue)") } catch { - self.logger.error("Watch 앱 상태 푸시 실패: \(error.localizedDescription)") + self.logger.error("실패: \(error.localizedDescription)") + self.watchState = state } } @@ -236,6 +239,11 @@ extension WatchConnectionManager: WCSessionDelegate { Task { @MainActor in self.onReceiveCaptureComplete?() } + } else if actionValue == ActionValue.pushState.rawValue { + self.logger.info("상태 푸시 명령 수신됨.") + Task { @MainActor in + self.pushWatchAppState(watchState) + } } }