Skip to content
Permalink
Browse files
CB-12922 (ios): fix In-app browser does not cede control
  • Loading branch information
jcesarmobile committed Jul 1, 2018
1 parent 26cf6e4 commit dac06aa3f3ad825cbcd326c0aaf0f36ebddd0cdd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
@@ -30,6 +30,7 @@
@class CDVInAppBrowserViewController;

@interface CDVInAppBrowser : CDVPlugin {
UIWindow * tmpWindow;
}

@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
@@ -239,8 +239,10 @@ - (void)show:(CDVInvokedUrlCommand*)command
// Run later to avoid the "took a long time" log message.
dispatch_async(dispatch_get_main_queue(), ^{
if (weakSelf.inAppBrowserViewController != nil) {
CGRect frame = [[UIScreen mainScreen] bounds];
UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame];
if (!tmpWindow) {
CGRect frame = [[UIScreen mainScreen] bounds];
tmpWindow = [[UIWindow alloc] initWithFrame:frame];
}
UIViewController *tmpController = [[UIViewController alloc] init];
[tmpWindow setRootViewController:tmpController];
[tmpWindow setWindowLevel:UIWindowLevelNormal];
@@ -270,7 +272,9 @@ - (void)hide:(CDVInvokedUrlCommand*)command
dispatch_async(dispatch_get_main_queue(), ^{
if (self.inAppBrowserViewController != nil) {
_previousStatusBarStyle = -1;
[self.inAppBrowserViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
[self.inAppBrowserViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
[[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible];
}];
}
});
}
@@ -835,9 +839,13 @@ - (void)close
// Run later to avoid the "took a long time" log message.
dispatch_async(dispatch_get_main_queue(), ^{
if ([weakSelf respondsToSelector:@selector(presentingViewController)]) {
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:^{
[[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible];
}];
} else {
[[weakSelf parentViewController] dismissViewControllerAnimated:YES completion:nil];
[[weakSelf parentViewController] dismissViewControllerAnimated:YES completion:^{
[[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible];
}];
}
});
}

0 comments on commit dac06aa

Please sign in to comment.