Skip to content

Instantly share code, notes, and snippets.

@DeSlaper
Created September 7, 2015 09:23
Show Gist options
  • Select an option

  • Save DeSlaper/491bcc74fe984a122522 to your computer and use it in GitHub Desktop.

Select an option

Save DeSlaper/491bcc74fe984a122522 to your computer and use it in GitHub Desktop.
Opening urls outside of Cordova / PhoneGap
IOS
===
If you need to open urls from within a phonegap/cordava app into safari add the following pice of code into
```
/<project-path>/platforms/ios/<project-name>/Classes/MainViewController.m
```
```
- (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/Cordova 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