fix(ble): restore peripheral state and keep advertising
This commit is contained in:
@@ -9,11 +9,13 @@ import SwiftUI
|
||||
|
||||
@main
|
||||
struct irisApp: App {
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@StateObject private var ble: BlePeripheralManager
|
||||
@StateObject private var orchestrator: ContextOrchestrator
|
||||
|
||||
init() {
|
||||
let bleManager = BlePeripheralManager()
|
||||
bleManager.start()
|
||||
_ble = StateObject(wrappedValue: bleManager)
|
||||
_orchestrator = StateObject(wrappedValue: ContextOrchestrator(ble: bleManager))
|
||||
}
|
||||
@@ -23,6 +25,11 @@ struct irisApp: App {
|
||||
ContentView()
|
||||
.environmentObject(ble)
|
||||
.environmentObject(orchestrator)
|
||||
.onChange(of: scenePhase) { phase in
|
||||
if phase == .active || phase == .background {
|
||||
ble.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user