Browse Source

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.

(cherry picked from commit ffed1c50c03c31774b9058b7694f44c3b4c84ca9)
(cherry picked from commit c6e1806ba9db09cff9549bf3e36c27def00f0e88)
Ryan C. Gordon 3 months ago
parent
commit
76816a3bfc
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/misc/ios/SDL_sysurl.m

+ 9 - 1
src/misc/ios/SDL_sysurl.m

@@ -29,7 +29,15 @@ int SDL_SYS_OpenURL(const char *url)
 
         NSString *nsstr = [NSString stringWithUTF8String:url];
         NSURL *nsurl = [NSURL URLWithString:nsstr];
-        return [[UIApplication sharedApplication] openURL:nsurl] ? 0 : -1;
+        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 0;
     }
 }