2

How to open URL in a web browser instead of webview in-app on Android App?

I used,

<ion-button  href="https://stackoverflow.com">StackOverFlow</ion-button>

The URL is opening in the in-app browser, I need to open an android system's default browser.

I have gone through the official document, I couldn't find useless information from there.

  1. https://beta.ionicframework.com/docs/api
  2. https://beta.ionicframework.com/docs/components#button
  3. https://beta.ionicframework.com/docs/api/button/
Aravin
  • 6,605
  • 5
  • 42
  • 58

2 Answers2

3

You want to read the cordova documentation it can b help you to find your solution.

_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.

Cordova https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/index.html

Ionic 4 https://ionicframework.com/docs/native/in-app-browser

Hassan Ali
  • 994
  • 6
  • 22
3

Capacitor

To programmatically open URLs (for example by binding to a (click) event of a button or link) in Capacitor you can use this:

Open externally:

Capacitor V2: Use the App API (https://capacitorjs.com/docs/apis/app) where you have a method canOpenUrl(…) and a method openUrl(…).

Capacitor V3: Use the AppLauncher API (https://capacitorjs.com/docs/v3/apis/app-launcher) where you have a method canOpenUrl(…) and a method openUrl(…).

Open in in-app browser:

If you want to open an URL in a so called in-app browser you can use the Browser API (@capacitor/browser plugin):

On Android this opens a Chrome WebView, on iOS a SFSafariViewController, so the user "kind of" stays in the app.

Klemens Zleptnig
  • 1,698
  • 20
  • 36