Fix AppDelegate window compatibility

This commit is contained in:
2026-07-07 14:22:43 +08:00
parent 6bdabadc3b
commit 234142ed69
2 changed files with 6 additions and 1 deletions
+2 -1
View File
@@ -10,7 +10,8 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
/// 兼容部分 Objective-C SDK 通过 UIApplicationDelegate.window 访问主窗口的场景。
@objc var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UmengBootstrap.configureIfNeeded()
+4
View File
@@ -22,12 +22,16 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window.rootViewController = AppRouter.makeRootViewController()
window.makeKeyAndVisible()
self.window = window
(UIApplication.shared.delegate as? AppDelegate)?.window = window
registerNotifications()
}
func sceneDidDisconnect(_ scene: UIScene) {
NotificationCenter.default.removeObserver(self)
if (UIApplication.shared.delegate as? AppDelegate)?.window === window {
(UIApplication.shared.delegate as? AppDelegate)?.window = nil
}
}
private func registerNotifications() {