I have below logic which give app state: But i wanted to add logic when app move to foreground.
In Swift we have method. I am looking for something similar method in swiftui
func sceneWillEnterForeground(_ scene: UIScene) {
but in Swiftui i only have .active, .inactive and .background
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
} else if newPhase == .inactive {
} else if newPhase == .background {
}
}
It is possible to use
.onReceivewith subscription to Notification Center publisher onUIScene.willEnterForegroundNotificationnotification, or, after all, mentioned scene delegate callback (having scene delegate as described in https://stackoverflow.com/a/60359809/12299030)