Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External Links to load OUTSIDE of Ionic / Cordova app

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?

like image 405
Francesco Fiori Avatar asked Apr 03 '15 10:04

Francesco Fiori


2 Answers

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.

like image 165
Sylvain Leroux Avatar answered Nov 04 '22 06:11

Sylvain Leroux


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.
*/
like image 35
Banik Avatar answered Nov 04 '22 07:11

Banik