From 1157eb743f0b31c6d772ca61a20506a1b747a432 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 26 Dec 2024 11:40:30 -0500 Subject: [PATCH 1/2] misc: Fix SDL_OpenURL on newer iOS releases. Apparently as of iOS 18.2, the deprecated API we were using just refuses to work at all. Fixes #11728. --- src/misc/ios/SDL_sysurl.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/misc/ios/SDL_sysurl.m b/src/misc/ios/SDL_sysurl.m index 9a504b21e2236..cc340bc350f4e 100644 --- a/src/misc/ios/SDL_sysurl.m +++ b/src/misc/ios/SDL_sysurl.m @@ -35,7 +35,15 @@ bool SDL_SYS_OpenURL(const char *url) #else NSString *nsstr = [NSString stringWithUTF8String:url]; NSURL *nsurl = [NSURL URLWithString:nsstr]; - return [[UIApplication sharedApplication] openURL:nsurl]; + if (![[UIApplication sharedApplication] canOpenURL:nsurl]) { + return SDL_SetError("No handler registerd for this type of URL"); + } + if (@available(iOS 10.0, *)) { + [[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:^(BOOL success) {}]; + } else { + [[UIApplication sharedApplication] openURL:nsurl]; + } + return true; #endif } } From 36fbe7dbbcd04d53fd5e4b9fcbdae36996840fb1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 26 Dec 2024 14:03:27 -0500 Subject: [PATCH 2/2] misc: Make SDL_OpenURL work with VisionOS, tvOS, etc. --- src/misc/ios/SDL_sysurl.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/misc/ios/SDL_sysurl.m b/src/misc/ios/SDL_sysurl.m index cc340bc350f4e..a2c3d0a3ef68a 100644 --- a/src/misc/ios/SDL_sysurl.m +++ b/src/misc/ios/SDL_sysurl.m @@ -29,22 +29,19 @@ bool SDL_SYS_OpenURL(const char *url) { @autoreleasepool { - -#ifdef SDL_PLATFORM_VISIONOS - return SDL_Unsupported(); // openURL is not supported on visionOS -#else NSString *nsstr = [NSString stringWithUTF8String:url]; NSURL *nsurl = [NSURL URLWithString:nsstr]; if (![[UIApplication sharedApplication] canOpenURL:nsurl]) { return SDL_SetError("No handler registerd for this type of URL"); } - if (@available(iOS 10.0, *)) { + if (@available(iOS 10.0, tvOS 10.0, *)) { [[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:^(BOOL success) {}]; } else { + #ifndef SDL_PLATFORM_VISIONOS // Fallback is never available in any version of VisionOS (but correct API always is). [[UIApplication sharedApplication] openURL:nsurl]; + #endif } return true; -#endif } }