Skip to content

Commit e2d8429

Browse files
authored
fix(iOS): IAB not showing up in apps using UIScenes (#1067)
1 parent dfde59d commit e2d8429

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Diff for: src/ios/CDVWKInAppBrowser.m

+13-4
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)