Skip to content

Commit dac06aa

Browse files
committed
CB-12922 (ios): fix In-app browser does not cede control
1 parent 26cf6e4 commit dac06aa

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/ios/CDVInAppBrowser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
@class CDVInAppBrowserViewController;
3131

3232
@interface CDVInAppBrowser : CDVPlugin {
33+
UIWindow * tmpWindow;
3334
}
3435

3536
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;

src/ios/CDVInAppBrowser.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,10 @@ - (void)show:(CDVInvokedUrlCommand*)command
239239
// Run later to avoid the "took a long time" log message.
240240
dispatch_async(dispatch_get_main_queue(), ^{
241241
if (weakSelf.inAppBrowserViewController != nil) {
242-
CGRect frame = [[UIScreen mainScreen] bounds];
243-
UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame];
242+
if (!tmpWindow) {
243+
CGRect frame = [[UIScreen mainScreen] bounds];
244+
tmpWindow = [[UIWindow alloc] initWithFrame:frame];
245+
}
244246
UIViewController *tmpController = [[UIViewController alloc] init];
245247
[tmpWindow setRootViewController:tmpController];
246248
[tmpWindow setWindowLevel:UIWindowLevelNormal];
@@ -270,7 +272,9 @@ - (void)hide:(CDVInvokedUrlCommand*)command
270272
dispatch_async(dispatch_get_main_queue(), ^{
271273
if (self.inAppBrowserViewController != nil) {
272274
_previousStatusBarStyle = -1;
273-
[self.inAppBrowserViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
275+
[self.inAppBrowserViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
276+
[[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible];
277+
}];
274278
}
275279
});
276280
}
@@ -835,9 +839,13 @@ - (void)close
835839
// Run later to avoid the "took a long time" log message.
836840
dispatch_async(dispatch_get_main_queue(), ^{
837841
if ([weakSelf respondsToSelector:@selector(presentingViewController)]) {
838-
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
842+
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:^{
843+
[[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible];
844+
}];
839845
} else {
840-
[[weakSelf parentViewController] dismissViewControllerAnimated:YES completion:nil];
846+
[[weakSelf parentViewController] dismissViewControllerAnimated:YES completion:^{
847+
[[[[UIApplication sharedApplication] delegate] window] makeKeyAndVisible];
848+
}];
841849
}
842850
});
843851
}

0 commit comments

Comments
 (0)