Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion GoogleSignIn/Sources/GIDEMMErrorHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,17 @@ - (BOOL)handleErrorFromResponse:(NSDictionary<NSString *, id> *)response

// This method is exposed to the unit test.
- (nullable UIWindow *)keyWindow {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
if (@available(iOS 15, *)) {
for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
if ([scene isKindOfClass:[UIWindowScene class]] &&
scene.activationState == UISceneActivationStateForegroundActive) {
return ((UIWindowScene *)scene).keyWindow;
}
}
} else {
} else
#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
{
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_15_0
if (@available(iOS 13, *)) {
for (UIWindow *window in UIApplication.sharedApplication.windows) {
Expand Down
5 changes: 4 additions & 1 deletion GoogleSignIn/Tests/Unit/GIDEMMErrorHandlerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,15 @@ - (void)testKeyWindow {
selector:@selector(sharedApplication)
isClassSelector:YES
withBlock:^{ return mockApplication; }];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
if (@available(iOS 15, *)) {
UIWindowScene *mockWindowScene = OCMClassMock([UIWindowScene class]);
OCMStub(mockApplication.connectedScenes).andReturn(@[mockWindowScene]);
OCMStub(mockWindowScene.activationState).andReturn(UISceneActivationStateForegroundActive);
OCMStub(mockWindowScene.keyWindow).andReturn(mockKeyWindow);
} else {
} else
#endif // __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000
{
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_15_0
if (@available(iOS 13, *)) {
OCMStub(mockApplication.windows).andReturn(@[mockKeyWindow]);
Expand Down