From 8e34787ee3c4bc3ba4bc5bb19b7e77d2a688be1d Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Wed, 28 Aug 2024 02:03:35 -0700 Subject: [PATCH] fix(iOS): IAB not showing up in apps using UIScenes --- 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];