Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UIApplication.connectedScenes on iOS 13 #4066

Merged
merged 2 commits into from Oct 15, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions Firebase/Auth/Source/Utilities/FIRAuthDefaultUIDelegate.m
Expand Up @@ -70,8 +70,26 @@ - (void)dismissViewControllerAnimated:(BOOL)flag completion:(nullable void (^)(v
applicationClass = cls;
}
}
UIApplication *application = [applicationClass sharedApplication];
UIViewController *topViewController = application.keyWindow.rootViewController;

UIViewController *topViewController;
if (@available(iOS 13.0, *)) {
UIApplication *application = [applicationClass sharedApplication];
NSSet<UIScene *> * connectedScenes = application.connectedScenes;
for (UIScene *scene in connectedScenes) {
if ([scene isKindOfClass:[UIWindowScene class]]) {
UIWindowScene *windowScene = (UIWindowScene *)scene;
for (UIWindow *window in windowScene.windows) {
if (window.isKeyWindow) {
topViewController = window.rootViewController;
}
}
}
}
} else {
UIApplication *application = [applicationClass sharedApplication];
topViewController = application.keyWindow.rootViewController;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: moving this code out to a separate method may improve readability of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried while it seems the code blocks depend on each other and hard to be separated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, no problem


while (true){
if (topViewController.presentedViewController) {
topViewController = topViewController.presentedViewController;
Expand Down