Skip to content

Commit 6e1ba33

Browse files
authored
Use initWithFrame: to create the in-app message window in non-UIScene apps (#7080)
* If the app doesn't have a scene delegate, use initWithFrame: to create the in-app message window * Refactor window creation method for iOS 13 and above * Add CHANGELOG entry * Fix CHANGELOG entry
1 parent f052459 commit 6e1ba33

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

FirebaseInAppMessaging/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 2020-12 -- v7.3.0
2+
- [fixed] Fixed default display bug in apps that don't use `UISceneDelegate` (#6803).
3+
14
# 2020-10 -- v7.0.0
25
- [removed] Removed deprecated elements of in-app messaging API.
36

FirebaseInAppMessaging/Sources/DefaultUI/FIRIAMRenderingWindowHelper.m

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ + (UIWindow *)UIWindowForModalView {
2929
dispatch_once(&onceToken, ^{
3030
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
3131
if (@available(iOS 13.0, *)) {
32-
UIWindowScene *foregroundedScene = [[self class] foregroundedScene];
33-
UIWindowForModal = [[UIWindow alloc] initWithWindowScene:foregroundedScene];
32+
UIWindowForModal = [[self class] iOS13PlusWindow];
3433
} else {
3534
#endif // defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
3635
UIWindowForModal = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
@@ -49,8 +48,7 @@ + (UIWindow *)UIWindowForBannerView {
4948
dispatch_once(&onceToken, ^{
5049
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
5150
if (@available(iOS 13.0, *)) {
52-
UIWindowScene *foregroundedScene = [[self class] foregroundedScene];
53-
UIWindowForBanner = [[FIRIAMBannerViewUIWindow alloc] initWithWindowScene:foregroundedScene];
51+
UIWindowForBanner = [[self class] iOS13PlusBannerWindow];
5452
} else {
5553
#endif // defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
5654
UIWindowForBanner =
@@ -71,8 +69,7 @@ + (UIWindow *)UIWindowForImageOnlyView {
7169
dispatch_once(&onceToken, ^{
7270
#if defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
7371
if (@available(iOS 13.0, *)) {
74-
UIWindowScene *foregroundedScene = [[self class] foregroundedScene];
75-
UIWindowForImageOnly = [[UIWindow alloc] initWithWindowScene:foregroundedScene];
72+
UIWindowForImageOnly = [[self class] iOS13PlusWindow];
7673
} else {
7774
#endif // defined(__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
7875
UIWindowForImageOnly = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
@@ -94,6 +91,25 @@ + (UIWindowScene *)foregroundedScene API_AVAILABLE(ios(13.0)) {
9491
}
9592
return nil;
9693
}
94+
95+
+ (UIWindow *)iOS13PlusWindow API_AVAILABLE(ios(13.0)) {
96+
UIWindowScene *foregroundedScene = [[self class] foregroundedScene];
97+
if (foregroundedScene.delegate) {
98+
return [[UIWindow alloc] initWithWindowScene:foregroundedScene];
99+
} else {
100+
return [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
101+
}
102+
}
103+
104+
+ (FIRIAMBannerViewUIWindow *)iOS13PlusBannerWindow API_AVAILABLE(ios(13.0)) {
105+
UIWindowScene *foregroundedScene = [[self class] foregroundedScene];
106+
if (foregroundedScene.delegate) {
107+
return [[FIRIAMBannerViewUIWindow alloc] initWithWindowScene:foregroundedScene];
108+
} else {
109+
return [[FIRIAMBannerViewUIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
110+
}
111+
}
112+
97113
#endif
98114
@end
99115

0 commit comments

Comments
 (0)