It seems you're not inquiring about creating a webview within an Ionic application, but rather about launching an external URL in the phone's default web browser, am I right?
To achieve this functionality, you can employ the cordova-plugin-whitelist
plugin. Once installed, you can configure it to handle various actions. Below, I've listed the default settings I typically use that prompt all external content to open outside of the app (specified in the config.xml
file):
<access origin="*"/>
<allow-intent href="http://*/*" launch-external="yes"/>
<allow-intent href="https://*/*" launch-external="yes"/>
<allow-intent href="tel:*" launch-external="yes"/>
<allow-intent href="sms:*" launch-external="yes"/>
<allow-intent href="mailto:*" launch-external="yes"/>
<allow-intent href="geo:*" launch-external="yes"/>
The access origin="*"
attribute informs the app that it has permission to access all external resources, utilizing the *
as a wildcard. Subsequently, by utilizing the allow-intent
with the launch-external
attribute set to yes
, the app recognizes that all links specified with the href
attribute should open externally.
The provided code guarantees that all external websites, phone numbers, text messages, emails, and even geographical locations are launched in native applications. It's essential to ensure that all links within the app adhere to the specified format mentioned above.