Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@main
struct MyApp: App {
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
ContentView()
}
.onChange(of: scenePhase) { phase in
if phase == .background {
//perform cleanup
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment