On my app I use the typical way for biometric authentication after coming back from background:
@main
struct MyApp: App {
@Environment(\.scenePhase) var phase
var body: some Scene {
WindowGroup {
MainView()
.onChange(of: phase) { (newPhase) in
switch newPhase {
case .active:
biometricsAuthentication()
case .inactive: print("App is inactive")
case .background: print("App is on background")
appBlocked = true
default: print("default")
}
}
}
}
Doing this way everything works OK, but there is a little moment MainView is visible BEFORE authentication method triggers, I supossed due to the fraction of time that app is .inactive, after coming back from .background.
On MacOS app version, I call this authentication method on AppDelegate "applicationDidFinishLaunching" method, and nothing at all is presented until authentication finishes. So, I've tried to emulate this on iOS, with a dedicated AppDelegate, and trying some methods, without success.
Is this the correct way of doing it? Is there a way to accomplish it?