I'm building a iOS app with Cordova 3.1. I have a link I would like to open in Safari. I've installed the org.apache.cordova.inappbrowser plugin and it worked well on my iPhone (iOS 7) and on the simulator (iOS5;iOS6.1;iOS7) but if I try (iOS6) on all devices it doesn't work.
Does anybody know how to fix this or tried it on a real device running iOS6? I'm using this code to open the link:
window.open('http://www.google.nl', '_system');
well I've implemented this through native side (Objective C)
Add this method in 'MainViewController.m'
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
NSString *str = url.absoluteString;
NSRange range = [str rangeOfString:@"http://"];
NSRange range1 = [str rangeOfString:@"https://"];
if (range.location != NSNotFound || range1.location != NSNotFound) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
This take cares of both 'http' and 'https' link for both iOS6 & iOS7, and opens the link in default browser of the device.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With