diff --git a/iphone/Classes/AppModule.m b/iphone/Classes/AppModule.m index bacd84d0de8..4c6ff86d0b6 100644 --- a/iphone/Classes/AppModule.m +++ b/iphone/Classes/AppModule.m @@ -49,7 +49,18 @@ - (void)_resumeRestart:(id)unused [TiLayoutQueue resetQueue]; #endif - UIScene *activeScene = UIApplication.sharedApplication.connectedScenes.allObjects.firstObject; + // Get the currently active scene + UIScene *activeScene = nil; + for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) { + if (scene.activationState == UISceneActivationStateForegroundActive) { + activeScene = scene; + break; + } + } + + if (activeScene == nil) { + NSLog(@"[ERROR] No active scene connected - this may lead to an undefined behavior"); + } /* Begin backgrounding simulation */ [appDelegate sceneWillResignActive:activeScene];