Created
September 7, 2015 09:23
-
-
Save DeSlaper/491bcc74fe984a122522 to your computer and use it in GitHub Desktop.
Opening urls outside of Cordova / PhoneGap
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
| 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