I have a simple Cordova wrapper app which points to an external webpage, without defining any of its own views.
I would like all internal links from that domain to be loaded inside the app, but all external links (http://twitter.com, etc) to be loaded in the system browser, so the pages have Back / Forward functionality.
In a normal app with views, I could set target='_system'
to load links in the default browser, or use the cordova-plugin-inappbrowser to explicitly open links in a web browser view. Unfortunately in this case I don't have the ability to edit the server side code, so need a solution that works within the app.
If I define the config.xml
as such, then both internal and external links are loaded in app.
<content src="http://example.com/" />
<access origin="*" />
<allow-navigation href="*" />
If I define the config.xml
with allow-intent
, then internal and external links are opened in the system browser.
<content src="http://example.com/" />
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
Others have suggested using custom javascript to override the target
to _system
, however since I don't have my own views I can't really do that.
Is it possible to define allow-intent
for the cordova-plugin-whitelist in such a way to include all URLs that are not the internal domain?
Or will I need to somehow override shouldStartLoadWithRequest
in MainViewController
and then call [[UIApplication sharedApplication] openURL:url]
?