I'm working in Swift UI 2.0 and currently have a setup as follows:
@main
struct MyApp: App {
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
InitialView()
}
.onChange(of: scenePhase) { (newScenePhase) in
switch newScenePhase {
case .active:
print("scene is now active!")
case .inactive:
print("scene is now inactive!")
case .background:
print("scene is now in the background!")
@unknown default:
print("sus")
}
}
}
}
which is fine but none of these account for the case when the application is terminated (i.e. a user double taps the home button and swipes up on the app). How can I account for this case?
I tried unsuccessfully implementing applicationWillTerminate(_:)
so any guidance here would be appreciated.
Thank you!