From 3845f729b959daf122d7883ce1c9ddb299b151e4 Mon Sep 17 00:00:00 2001 From: Themis wang Date: Thu, 7 Nov 2024 19:22:25 -0500 Subject: [PATCH] find a even better api --- .../UIKit/FPRUIViewControllerInstrument.m | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/FirebasePerformance/Sources/Instrumentation/UIKit/FPRUIViewControllerInstrument.m b/FirebasePerformance/Sources/Instrumentation/UIKit/FPRUIViewControllerInstrument.m index ab5bbfbf99e..1c2226148ca 100644 --- a/FirebasePerformance/Sources/Instrumentation/UIKit/FPRUIViewControllerInstrument.m +++ b/FirebasePerformance/Sources/Instrumentation/UIKit/FPRUIViewControllerInstrument.m @@ -69,36 +69,9 @@ void InstrumentViewDidAppear(FPRUIViewControllerInstrument *instrument, // This has to be called on the main thread and so it's done here instead of in // FPRScreenTraceTracker. -#if !defined(TARGET_OS_VISION) || !TARGET_OS_VISION - NSArray *windows = nil; - - if (@available(iOS 13.0, *)) { - NSArray *scenes = FPRSharedApplication().connectedScenes.allObjects; - for (UIScreen *scene in scenes) { - if ([scene isKindOfClass:[UIWindowScene class]]) { - windows = [(UIWindowScene *)scene windows]; - break; - } - } - } else { - windows = FPRSharedApplication().windows; - } - - if (!windows || windows.count == 0) { - return; - } - - UIWindow *foundKeyWindow = nil; - for (UIWindow *window in windows) { - if (window.isKeyWindow) { - foundKeyWindow = window; - break; - } - } - if (foundKeyWindow && [((UIViewController *)_self).view isDescendantOfView:foundKeyWindow]) { + if (FPRSharedApplication() && ((UIViewController *)_self).view.window.keyWindow) { [[FPRScreenTraceTracker sharedInstance] viewControllerDidAppear:_self]; } -#endif }]; }