Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ios/Classes/AliAuthPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<UIScene *> *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;
Expand Down