I have an SwiftUI App which I made for iPhone/iPads.
Now I'm trying to transfer it to macOS. One problem I am struggling with is this code block:
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
print("Never called on macOS. Works fine on iPhones.")
// Do some more stuff.
}
Apple documentations says its available on Mac Catalyst 13.0+, but this code never gets called on macOS.
So my question is:
Where do you put macCatalyst code that should be executed once the program starts (TouchID authentication, e.g.)?
Where do you put macCatalyst code that should be executed once the program starts (TouchID authentication, e.g.)?
In SceneDelegate
func sceneDidBecomeActive(_ scene: UIScene) {
print(#function);
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}
it is called once application started in macCatalyst.