Last active
December 14, 2015 02:29
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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