misc: Make SDL_OpenURL work with VisionOS, tvOS, etc.
(cherry picked from commit7bbe6025be) (cherry picked from commite55a23050e)
This commit is contained in:
1 file changed
+3
-2
@@ -26,16 +26,17 @@
|
|||||||
int SDL_SYS_OpenURL(const char *url)
|
int SDL_SYS_OpenURL(const char *url)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
NSString *nsstr = [NSString stringWithUTF8String:url];
|
NSString *nsstr = [NSString stringWithUTF8String:url];
|
||||||
NSURL *nsurl = [NSURL URLWithString:nsstr];
|
NSURL *nsurl = [NSURL URLWithString:nsstr];
|
||||||
if (![[UIApplication sharedApplication] canOpenURL:nsurl]) {
|
if (![[UIApplication sharedApplication] canOpenURL:nsurl]) {
|
||||||
return SDL_SetError("No handler registerd for this type of URL");
|
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) {}];
|
[[UIApplication sharedApplication] openURL:nsurl options:@{} completionHandler:^(BOOL success) {}];
|
||||||
} else {
|
} else {
|
||||||
|
#ifndef SDL_PLATFORM_VISIONOS /* Fallback is never available in any version of VisionOS (but correct API always is). */
|
||||||
[[UIApplication sharedApplication] openURL:nsurl];
|
[[UIApplication sharedApplication] openURL:nsurl];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user