|
14 | 14 |
|
15 | 15 | #import <TargetConditionals.h> |
16 | 16 | #import <UIKit/UIKit.h> |
| 17 | +#import <UIKit/UIWindowScene.h> |
17 | 18 |
|
18 | 19 | #import "FirebasePerformance/Sources/AppActivity/FPRScreenTraceTracker+Private.h" |
19 | 20 | #import "FirebasePerformance/Sources/Common/FPRDiagnostics.h" |
@@ -69,12 +70,22 @@ void InstrumentViewDidAppear(FPRUIViewControllerInstrument *instrument, |
69 | 70 |
|
70 | 71 | // This has to be called on the main thread and so it's done here instead of in |
71 | 72 | // FPRScreenTraceTracker. |
72 | | - // TODO(#13067): Replace keyWindow usage (deprecated in iOS and unavailable in visionOS). |
73 | 73 | #if !defined(TARGET_OS_VISION) || !TARGET_OS_VISION |
74 | | -#pragma clang diagnostic push |
75 | | -#pragma clang diagnostic ignored "-Wdeprecated-declarations" |
76 | | - if ([((UIViewController *)_self).view isDescendantOfView:FPRSharedApplication().keyWindow]) { |
77 | | -#pragma clang diagnostic pop |
| 74 | + NSArray *windows; |
| 75 | + if (@available(iOS 13.0, *)) { |
| 76 | + NSArray *scenes = FPRSharedApplication().connectedScenes.allObjects; |
| 77 | + windows = [[scenes objectAtIndex:0] windows]; |
| 78 | + } else { |
| 79 | + windows = FPRSharedApplication().windows; |
| 80 | + } |
| 81 | + UIWindow *foundKeyWindow; |
| 82 | + for (UIWindow *window in windows) { |
| 83 | + if (window.isKeyWindow) { |
| 84 | + foundKeyWindow = window; |
| 85 | + break; |
| 86 | + } |
| 87 | + } |
| 88 | + if (foundKeyWindow && [((UIViewController *)_self).view isDescendantOfView:foundKeyWindow]) { |
78 | 89 | [[FPRScreenTraceTracker sharedInstance] viewControllerDidAppear:_self]; |
79 | 90 | } |
80 | 91 | #endif |
|
0 commit comments