Skip to content

Commit 8e34787

Browse files
committed
fix(iOS): IAB not showing up in apps using UIScenes
1 parent dfde59d commit 8e34787

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/ios/CDVWKInAppBrowser.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,20 @@ - (void)show:(CDVInvokedUrlCommand*)command withNoAnimate:(BOOL)noAnimate
246246
float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
247247
__strong __typeof(weakSelf) strongSelf = weakSelf;
248248
if (!strongSelf->tmpWindow) {
249-
CGRect frame = [[UIScreen mainScreen] bounds];
250-
if(initHidden && osVersion < 11){
251-
frame.origin.x = -10000;
249+
if (@available(iOS 13.0, *)) {
250+
UIWindowScene *scene = strongSelf.viewController.view.window.windowScene;
251+
if (scene) {
252+
strongSelf->tmpWindow = [[UIWindow alloc] initWithWindowScene:scene];
253+
}
254+
}
255+
256+
if (!strongSelf->tmpWindow) {
257+
CGRect frame = [[UIScreen mainScreen] bounds];
258+
if(initHidden && osVersion < 11){
259+
frame.origin.x = -10000;
260+
}
261+
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
252262
}
253-
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
254263
}
255264
UIViewController *tmpController = [[UIViewController alloc] init];
256265
[strongSelf->tmpWindow setRootViewController:tmpController];

0 commit comments

Comments
 (0)