Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import WatchConnectivity

final class WatchConnectionManager: NSObject {
private enum ActionValue: String {
case pushState
case capture
case connect
case prepare
Expand Down Expand Up @@ -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 활성화 성공")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import WatchConnectivity

final class WatchConnectionManager: NSObject {
private enum ActionValue: String {
case pushState
case capture
case connect
case prepare
Expand All @@ -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)?

Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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)
}
}
}

Expand Down