In iOS we can use scenePhase to detect when the app is foregrounded and use that as an opportunity to refresh data.
It does not appear to work in visionOS for apps that remain open. I need a way of refreshing data and I am struggling to find the correct lifecycle event to initiate it.
.onChange(of: scenePhase) { _, newPhase in
switch newPhase {
case .active:
// Would like to refresh data but this is only called when
// closing the app and reopening it. Not when looking at the app
// (or even interacting with the app) after looking at another app
default: return
}
}