Bläddra i källkod

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.
Ryan C. Gordon 3 månader sedan
förälder
incheckning
ffed1c50c0
1 ändrade filer med 9 tillägg och 1 borttagningar
  1. 9 1
      src/misc/ios/SDL_sysurl.m

+ 9 - 1
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
     }
 }