From 290f0c831fe47d0c91a377e4b843a7599358a892 Mon Sep 17 00:00:00 2001 From: Jason Millard Date: Fri, 27 Mar 2026 22:08:07 -0400 Subject: [PATCH] iOS: Fix SDL_EVENT_DROP_FILE lost on cold start from URL open --- src/video/uikit/SDL_uikitappdelegate.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index 4f40d93dcf..d4a8c07f87 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -352,6 +352,7 @@ API_AVAILABLE(ios(13.0)) @implementation SDLUIKitSceneDelegate { UIWindow *launchWindow; + NSMutableArray *launchURLs; } + (NSString *)getSceneDelegateClassName @@ -411,15 +412,16 @@ API_AVAILABLE(ios(13.0)) // Set working directory to resource path [[NSFileManager defaultManager] changeCurrentDirectoryPath:[bundle resourcePath]]; - // Handle any connection options (like opening URLs) + launchURLs = [[NSMutableArray alloc] init]; + for (NSUserActivity *activity in connectionOptions.userActivities) { if (activity.webpageURL) { - [self handleURL:activity.webpageURL]; + [launchURLs addObject:activity.webpageURL]; } } for (UIOpenURLContext *urlContext in connectionOptions.URLContexts) { - [self handleURL:urlContext.URL]; + [launchURLs addObject:urlContext.URL]; } SDL_SetMainReady(); @@ -488,6 +490,7 @@ API_AVAILABLE(ios(13.0)) - (void)postFinishLaunch { [self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0]; + [self performSelector:@selector(processLaunchURLs) withObject:nil afterDelay:0.0]; SDL_SetiOSEventPump(true); exit_status = SDL_CallMainFunction(forward_argc, forward_argv, forward_main); @@ -499,6 +502,14 @@ API_AVAILABLE(ios(13.0)) } } +- (void)processLaunchURLs +{ + for (NSURL *url in launchURLs) { + [self handleURL:url]; + } + launchURLs = nil; +} + - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options API_AVAILABLE(ios(13.0)) { // This doesn't appear to be called, but it needs to be implemented to signal that we support the UIScene life cycle