UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead

Forums > Swift

I've been using this code on an app for a while to make sure that whenever it is opened, it always defaults back to the login page, no matter what. But with the advent of iOS 15.0 i've started gettting the warning:

"'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead"

.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) { _ in
    if let window = UIApplication.shared.windows.first {
        window.rootViewController = UIHostingController(rootView: AuthenticateView(settings: settings, theCollection: theCollection))
        window.makeKeyAndVisible()
    }
}

is there a better way to make an app always open on a login page, no matter what? I don't understand enough about what it's doing to make the warning go away. The scheme is that anytime the app passes into the background, it goes to the login page before anyone can get back into it. I have the exact code above sprinkled thru my app on every view, so no matter which view is active, if the app goes into the background it'll default back to the login page. I think I got the original code from Stack Overflow.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.