Skip to content

Instantly share code, notes, and snippets.

@alejandrodazal
Last active August 29, 2015 14:08
Show Gist options
  • Save alejandrodazal/430d7872b7861930e5a0 to your computer and use it in GitHub Desktop.
Save alejandrodazal/430d7872b7861930e5a0 to your computer and use it in GitHub Desktop.
// code here...
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
// return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
NSURL *url = [request URL];
NSString *path = [url path];
// 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"]) {
if (
([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) &&
([[url parameterString] isEqualToString:@"external"] || [path rangeOfString:@"/external/"].location == NSNotFound)
) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
// code here...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment