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

Viewed 7986
2 Answers

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.

Related