Skip to content

Instantly share code, notes, and snippets.

@nowherenearithaca
Last active December 14, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nowherenearithaca/5014159 to your computer and use it in GitHub Desktop.
Save nowherenearithaca/5014159 to your computer and use it in GitHub Desktop.
Snippet for handling external links in a PhoneGap app. I don't know the original source for this.
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment