Skip to content

Instantly share code, notes, and snippets.

@g0ody
Last active December 15, 2015 17:59
Show Gist options
  • Save g0ody/5300406 to your computer and use it in GitHub Desktop.
Save g0ody/5300406 to your computer and use it in GitHub Desktop.
Cordova 2.5 iOS open http/https/mailto/fb urls external Add this to MainViewController.m
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL]; // URL that was requested
NSLog(@"OpenUrl: %@", [request URL]);
// Test that URL scheme is either HTTP(S)
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"] || [[url scheme] isEqualToString:@"fb"] || [[url scheme] isEqualToString:@"mailto"]) {
[[UIApplication sharedApplication] openURL:url]; // forward to application router
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