- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType: (UIWebViewNavigationType)navigationType
{
NSURL* url = [request URL];
switch (navigationType) {
case UIWebViewNavigationTypeLinkClicked:
// Note that the rejection strings will *only* print if
// it's a link click (and url is not whitelisted by <allow-*>)
if ([self.allowIntentsWhitelist URLIsAllowed:url]) {
// the url *is* in a <allow-intent> tag, push to the system
[[UIApplication sharedApplication] openURL:url];
return NO;
}
// fall through, to check whether you can load this in the webview
default:
// check whether we can internally navigate to this url
return ([self.allowNavigationsWhitelist URLIsAllowed:url]);
}
}
allowNavigationsWhitelistis the magic permission handler.
Add your url to the whitelist and let the code do it's job. Nothing to override.
https://cordova.apache.org/docs/en/latest/config_ref/#allow-navigation
--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
As you mentioned in the linked post, you're also trying to wrap an external site. I'm going to suggest that doing so isn't in your or your users best interests (just because something is /technically/ possible doesn't mean that it is wise). Wrapping an external site leads to all sorts of security and usability problems, and if you're targeting the Apple App Store, you'll also be set up for rejection -- Apple doesn't like apps that wrap websites.
<code>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
...
<allow-navigation href="http://192.168.1.157:8081/*" />
<allow-navigation href="*" />
</code>
(Apologies for any formatting; I'm on my iPad, and the editor given by Google has fewer features)
Note that the code you posted from the plugin checks if the URL is listed as an intent, and if so, it pushes to the system. You have such an intent listed in lines 2 and 3. And voila, your links open in a separate browser, rather than internally. Remove the intent tags and the problem should vanish.
That said, see my earlier post about the fact that wrapping a web site is not a good idea in the first place.