From 8810c6a8a0300eef154246c1007acfc862238e57 Mon Sep 17 00:00:00 2001 From: Niklas Merz Date: Fri, 6 Sep 2019 08:29:55 +0200 Subject: [PATCH] (ios) Fix inappbrowser not opening on iOS 13 by using reusable window Closes #492 --- src/ios/CDVWKInAppBrowser.h | 2 ++ src/ios/CDVWKInAppBrowser.m | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.h b/src/ios/CDVWKInAppBrowser.h index 1f359b1..7fddf9c 100644 --- a/src/ios/CDVWKInAppBrowser.h +++ b/src/ios/CDVWKInAppBrowser.h @@ -27,6 +27,8 @@ @class CDVWKInAppBrowserViewController; @interface CDVWKInAppBrowser : CDVPlugin { + UIWindow * tmpWindow; + @private NSString* _beforeload; BOOL _waitForBeforeload; diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 3b039f5..e03d5c9 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -314,17 +314,18 @@ static CDVWKInAppBrowser* instance = nil; dispatch_async(dispatch_get_main_queue(), ^{ if (weakSelf.inAppBrowserViewController != nil) { float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; - CGRect frame = [[UIScreen mainScreen] bounds]; - if(initHidden && osVersion < 11){ - frame.origin.x = -10000; + if (!tmpWindow) { + CGRect frame = [[UIScreen mainScreen] bounds]; + if(initHidden && osVersion < 11){ + frame.origin.x = -10000; + } + tmpWindow = [[UIWindow alloc] initWithFrame:frame]; } - - UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame]; UIViewController *tmpController = [[UIViewController alloc] init]; - + [tmpWindow setRootViewController:tmpController]; [tmpWindow setWindowLevel:UIWindowLevelNormal]; - + if(!initHidden || osVersion < 11){ [tmpWindow makeKeyAndVisible]; }