Skip to content

Instantly share code, notes, and snippets.

@palaniraja
Created January 23, 2015 13:43
Show Gist options
  • Select an option

  • Save palaniraja/56155d43e8b85d09dc28 to your computer and use it in GitHub Desktop.

Select an option

Save palaniraja/56155d43e8b85d09dc28 to your computer and use it in GitHub Desktop.
Ionic / Cordova webview external links - Add the method in your MainViewController.m file.
- (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 ];
}
}
@mauroa

mauroa commented Oct 12, 2015

Copy link
Copy Markdown

Is there any way of doing this without touching ObjectiveC code? Meaning, directly from Javascript (like Ionic or Cordova code)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment