From 9124902bc2c4c41d03e82624c610d3773b1fff32 Mon Sep 17 00:00:00 2001 From: iceDays Date: Sun, 15 Feb 2026 19:59:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20iOS26=20=E5=BC=BA=E5=88=B6=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=20UIScene=20=E4=B8=8B=20VC=20=E6=9F=A5=E6=89=BE?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/AliAuthPlugin.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ios/Classes/AliAuthPlugin.m b/ios/Classes/AliAuthPlugin.m index 2fe0dc6..48f3e3d 100644 --- a/ios/Classes/AliAuthPlugin.m +++ b/ios/Classes/AliAuthPlugin.m @@ -655,6 +655,23 @@ - (UIViewController *)getRootViewController { #pragma mark ======在view上添加UIViewController======== - (UIViewController *)findCurrentViewController{ UIWindow *window = [[UIApplication sharedApplication].delegate window]; + + // 如果未获取到 window 且系统为 iOS 13+,尝试使用 connectedScenes + if (!window && @available(iOS 13.0, *)) { + NSSet *scenes = [UIApplication sharedApplication].connectedScenes; + for (UIScene *scene in scenes) { + if ([scene isKindOfClass:[UIWindowScene class]] && scene.activationState == UISceneActivationStateForegroundActive) { + UIWindowScene *windowScene = (UIWindowScene *)scene; + for (UIWindow *w in windowScene.windows) { + if (w.isKeyWindow) { + window = w; + break; + } + } + if (window) break; + } + } + } // UIViewController * vc = [[ViewController alloc] init]; // window.rootViewController = vc;