From e2d8429092b5d121745911530091fe9eb1f27c43 Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Thu, 29 Aug 2024 23:58:15 -0700 Subject: [PATCH] fix(iOS): IAB not showing up in apps using UIScenes (#1067) --- src/ios/CDVWKInAppBrowser.m | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index a121fb19d..cee483091 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -246,11 +246,20 @@ - (void)show:(CDVInvokedUrlCommand*)command withNoAnimate:(BOOL)noAnimate float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; __strong __typeof(weakSelf) strongSelf = weakSelf; if (!strongSelf->tmpWindow) { - CGRect frame = [[UIScreen mainScreen] bounds]; - if(initHidden && osVersion < 11){ - frame.origin.x = -10000; + if (@available(iOS 13.0, *)) { + UIWindowScene *scene = strongSelf.viewController.view.window.windowScene; + if (scene) { + strongSelf->tmpWindow = [[UIWindow alloc] initWithWindowScene:scene]; + } + } + + if (!strongSelf->tmpWindow) { + CGRect frame = [[UIScreen mainScreen] bounds]; + if(initHidden && osVersion < 11){ + frame.origin.x = -10000; + } + strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame]; } - strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame]; } UIViewController *tmpController = [[UIViewController alloc] init]; [strongSelf->tmpWindow setRootViewController:tmpController];