Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Browser Tab

Improve this doc

This plugin provides an interface to in-app browser tabs that exist on some mobile platforms, specifically Custom Tabs on Android (including the Chrome Custom Tabs implementation), and SFSafariViewController on iOS.

Repo: https://github.com/google/cordova-plugin-browsertab

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-browsertab
    $ npm install --save @ionic-native/browser-tab@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { BrowserTab } from '@ionic-native/browser-tab';

constructor(private browserTab: BrowserTab) {

  browserTab.isAvailable()
    .then(isAvailable => {
      if (isAvailable) {
        browserTab.openUrl('https://ionic.io');
      } else {
        // open URL with InAppBrowser instead or SafariViewController
      }
    });
}

Instance Members

isAvailable()

Check if BrowserTab option is available

Returns: Promise<any> Returns a promise that resolves when check is successful and returns true or false

openUrl(url)

Opens the provided URL using a browser tab

Param Type Details
url string

The URL you want to open

Returns: Promise<any> Returns a promise that resolves when check open was successful

close()

Closes browser tab

Returns: Promise<any> Returns a promise that resolves when close was finished

API

Native

General