From 3d4e4e7521ccd5aa6439926f11c99f8a34bf66a9 Mon Sep 17 00:00:00 2001 From: Dan Rosser Date: Thu, 5 Nov 2026 14:31:12 +1100 Subject: [PATCH] iOS / tvOS: deliver opened URLs via scene:openURLContexts: UIKit on iOS 13+ / 26+ and tvOS 13+ / 26+ sends URLs to UIWindowSceneDelegate scene:openURLContexts:, not application:handleOpenURL: (unavailable on tvOS, deprecated on iOS). ofxiOSSceneDelegate is already that scene delegate. Stop forwarding to handleOpenURL:. Call application:openURL:options: when the app delegate implements it, otherwise ofxiOSAlerts.launchedWithURL. ofxiOSAppDelegate now implements application:openURL:options: the same way ofxtvOSAppDelegate does. handleOpenURL: remains on iOS only as a wrapper for pre-scene UIKit. --- addons/ofxiOS/src/app/ofAppiOSWindow.mm | 22 ++++++++++++--------- addons/ofxiOS/src/core/ofxiOSAppDelegate.h | 4 ++++ addons/ofxiOS/src/core/ofxiOSAppDelegate.mm | 8 +++++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/addons/ofxiOS/src/app/ofAppiOSWindow.mm b/addons/ofxiOS/src/app/ofAppiOSWindow.mm index 5ba157d7d29..7b015e0efb2 100644 --- a/addons/ofxiOS/src/app/ofAppiOSWindow.mm +++ b/addons/ofxiOS/src/app/ofAppiOSWindow.mm @@ -45,7 +45,10 @@ #endif #include "ofxiOSGLKView.h" #include "ofxiOSEAGLView.h" +#include "ofxiOSAlerts.h" +// iOS 13+ / 26+: Info.plist UIApplicationSceneManifest names this class. +// UIKit delivers opened URLs to scene:openURLContexts:. @interface ofxiOSSceneDelegate : UIResponder @property (strong, nonatomic) UIWindow * window; @end @@ -84,17 +87,18 @@ - (void)sceneDidEnterBackground:(UIScene *)scene { - (void)scene:(UIScene *)scene openURLContexts:(NSSet *)URLContexts { id appDelegate = [UIApplication sharedApplication].delegate; for (UIOpenURLContext * context in URLContexts) { - if ([appDelegate respondsToSelector:@selector(application:openURL:options:)]) { - [appDelegate application:[UIApplication sharedApplication] openURL:context.URL options:@{}]; + NSURL * url = context.URL; + if (!url) { + continue; } -#if !TARGET_OS_TV - else if ([appDelegate respondsToSelector:@selector(application:handleOpenURL:)]) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [appDelegate application:[UIApplication sharedApplication] handleOpenURL:context.URL]; -#pragma clang diagnostic pop + if ([appDelegate respondsToSelector:@selector(application:openURL:options:)]) { + [appDelegate application:[UIApplication sharedApplication] openURL:url options:@{}]; + } else { + NSString * urlData = [url absoluteString]; + if (urlData) { + ofxiOSAlerts.launchedWithURL([urlData UTF8String]); + } } -#endif } } diff --git a/addons/ofxiOS/src/core/ofxiOSAppDelegate.h b/addons/ofxiOS/src/core/ofxiOSAppDelegate.h index a43f7b242ab..6b76e26c64f 100644 --- a/addons/ofxiOS/src/core/ofxiOSAppDelegate.h +++ b/addons/ofxiOS/src/core/ofxiOSAppDelegate.h @@ -50,6 +50,10 @@ @property (nonatomic, strong) UIViewController * uiViewController; @property (readonly) NSInteger currentScreenIndex; +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + options:(NSDictionary *)options; + - (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url; diff --git a/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm b/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm index c98916523f7..6a8e4d8430c 100644 --- a/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm +++ b/addons/ofxiOS/src/core/ofxiOSAppDelegate.mm @@ -221,13 +221,19 @@ - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { ofxiOSAlerts.gotMemoryWarning(); } -- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + options:(NSDictionary *)options { NSString *urlData = [url absoluteString]; const char * response = [urlData UTF8String]; ofxiOSAlerts.launchedWithURL(response); return YES; } +- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { + return [self application:application openURL:url options:@{}]; +} + //------------------------------------------------------------------------------------------- #ifdef __IPHONE_6_0 -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {