In ios17 and above, I can detect when swiftUI app goes into and out of background using:
@Environment(\.scenePhase) private var phase
... .onChange(of: phase) { switch phase { case .background: print("entering background...") case .active: print("entering foreground...") default: break } }
Is there a straightforward way to do this in SwiftUI for ios 16? I've found some examples using UIKit, but I am not that swift (sorry, couldn't resist) with that framework.