Skip to content

Commit

Permalink
misc: Fix SDL_OpenURL on newer iOS releases.
Browse files Browse the repository at this point in the history
Apparently as of iOS 18.2, the deprecated API we were using just refuses to
work at all.

Fixes libsdl-org#11728.

(cherry picked from commit ffed1c5)
(cherry picked from commit c6e1806)
  • Loading branch information
icculus committed Dec 27, 2024
1 parent ea873d3 commit 76816a3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/misc/ios/SDL_sysurl.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 76816a3

Please sign in to comment.