I'm working on a Ionic / Cordova app where I load feeds and news that sometimes contain external links. I need to load those external links outside of the app, not in the InAppBrowser but in the phone browser.
Is it possible to do this as a default behavior on all links?
In order to open URL using the corresponding system application you need the whitelist plugin. If your project is based on the scaffolded demo program, it should already be installed. If not (or simply to ensure that) :
ionic plugin add cordova-plugin-whitelist
Once the plug-in is installed, you will have to specify the intend you want to open from your application. In your config.xml, add:
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
...
Given the above rules, all URI stating with one of the specified protocols (http, https, tel, sms, mailto, ...) will be open using the corresponding system application. Of course, you can be much more specific by replacing the *
wildcards by actual values.
See this article for additional details.
For external links you have to use the inAppbrowser Plugin.For your reqiurment after including the plugin to open in phone browser. use the code
var ref = window.open('http://apache.org', '_system', 'location=yes');
/*
_self: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in the InAppBrowser.
_blank: Opens in the InAppBrowser.
_system: Opens in the system's web browser.
*/
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