Created
July 25, 2020 03:29
-
-
Save DnV1eX/f6bf0fddb27f4db9013bdae56cfa8786 to your computer and use it in GitHub Desktop.
Restore calling UIApplicationDelegate methods on UIApplication state change when using UIWindowSceneDelegate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@available(iOS 13.0, *) | |
class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
func sceneWillResignActive(_ scene: UIScene) { | |
if !UIApplication.shared.connectedScenes.contains(where: { $0.activationState == .foregroundActive && $0 != scene }) { | |
UIApplication.shared.delegate?.applicationWillResignActive?(.shared) | |
} | |
} | |
func sceneDidEnterBackground(_ scene: UIScene) { | |
if !UIApplication.shared.connectedScenes.contains(where: { $0.activationState == .foregroundActive || $0.activationState == .foregroundInactive }) { | |
UIApplication.shared.delegate?.applicationDidEnterBackground?(.shared) | |
} | |
} | |
func sceneWillEnterForeground(_ scene: UIScene) { | |
if !UIApplication.shared.connectedScenes.contains(where: { $0.activationState == .foregroundActive || $0.activationState == .foregroundInactive }) { | |
UIApplication.shared.delegate?.applicationWillEnterForeground?(.shared) | |
} | |
} | |
func sceneDidBecomeActive(_ scene: UIScene) { | |
if !UIApplication.shared.connectedScenes.contains(where: { $0.activationState == .foregroundActive && $0 != scene }) { | |
UIApplication.shared.delegate?.applicationDidBecomeActive?(.shared) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment