Skip to content

Commit

Permalink
Fixed iOS 13 openURL crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ddaddy committed Oct 6, 2019
1 parent e9cc5bb commit ee932ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 16 additions & 2 deletions Demo/Source/DemoTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,14 @@ - (void)linkPushed:(DTLinkButton *)button

if ([[UIApplication sharedApplication] canOpenURL:[URL absoluteURL]])
{
[[UIApplication sharedApplication] openURL:[URL absoluteURL]];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[URL absoluteURL] options:@{} completionHandler:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] openURL:[URL absoluteURL]];
#pragma clang diagnostic pop
}
}
else
{
Expand All @@ -652,7 +659,14 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
{
if (buttonIndex != actionSheet.cancelButtonIndex)
{
[[UIApplication sharedApplication] openURL:[self.lastActionLink absoluteURL]];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[self.lastActionLink absoluteURL] options:@{} completionHandler:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] openURL:[self.lastActionLink absoluteURL]];
#pragma clang diagnostic pop
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion Demo/Source/DemoWebVideoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
#if !defined(DT_APP_EXTENSIONS)
if (shouldOpenExternalURL)
{
[[UIApplication sharedApplication] openURL:[request URL]];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:[request URL] options:@{} completionHandler:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] openURL:[request URL]];
#pragma clang diagnostic pop
}
}
#endif

Expand Down

0 comments on commit ee932ea

Please sign in to comment.