Last active
December 15, 2015 17:59
-
-
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
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]; // 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