Skip to content

Commit 5499be9

Browse files
committed
updated keywindow code
1 parent ad62726 commit 5499be9

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

IdentityCore/src/util/ios/UIApplication+MSIDExtensions.m

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,17 @@ + (UIViewController *)msidCurrentViewController:(UIViewController *)parentContro
3636

3737
if ([MSIDAppExtensionUtil isExecutingInAppExtension]) return nil;
3838

39-
NSArray<UIScene *> *scenes; NSArray<UIWindow *> *windows;
40-
41-
scenes = [[[MSIDAppExtensionUtil sharedApplication] connectedScenes] allObjects];
42-
43-
if (scenes && scenes.count != 0)
44-
{
45-
windows = [(UIWindowScene *)[scenes objectAtIndex:0] windows];
46-
}
47-
48-
for (UIWindow *window in windows)
39+
for (UIWindowScene* scene in [[MSIDAppExtensionUtil sharedApplication] connectedScenes])
4940
{
50-
if (window.isKeyWindow)
41+
if (scene.activationState == UISceneActivationStateForegroundActive)
5142
{
52-
return [self msidCurrentViewControllerWithRootViewController:window.rootViewController];
43+
for (UIWindow *window in scene.windows)
44+
{
45+
if (window.isKeyWindow)
46+
{
47+
return [self msidCurrentViewControllerWithRootViewController:window.rootViewController];
48+
}
49+
}
5350
}
5451
}
5552

0 commit comments

Comments
 (0)