fix(watch-connectivity): improve WCSession lifecycle and message reliability
This commit is contained in:
@@ -1,15 +1,24 @@
|
||||
import SwiftUI
|
||||
import WatchConnectivity
|
||||
|
||||
@main
|
||||
struct SwimTrackerWatchApp: App {
|
||||
@StateObject private var workoutManager = WorkoutManager()
|
||||
|
||||
init() {
|
||||
if WCSession.isSupported() {
|
||||
let session = WCSession.default
|
||||
session.delegate = PhoneConnector.shared
|
||||
session.activate()
|
||||
}
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environmentObject(workoutManager)
|
||||
.onAppear {
|
||||
PhoneConnector.shared.setup(workoutManager: workoutManager)
|
||||
PhoneConnector.shared.workoutManager = workoutManager
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user