SafariViewController

Improve this doc

$ ionic plugin add cordova-plugin-safariviewcontroller

Repo: https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller

Supported platforms

Usage

import { SafariViewController } from 'ionic-native';


SafariViewController.isAvailable()
  .then(
    (available: boolean) => {
      if(available){

        SafariViewController.show({
          url: 'http://ionic.io',
          hidden: false,
          animated: false,
          transition: 'curl',
          enterReaderModeIfAvailable: true,
          tintColor: '#ff0000'
        })
        .then(
          (result: any) => {
            if(result.event === 'opened') console.log('Opened');
            else if(result.event === 'loaded') console.log('Loaded');
            else if(result.event === 'closed') console.log('Closed');
          },
          (error: any) => console.error(error)
        );

      } else {
        // use fallback browser, example InAppBrowser
      }
    }
  );

Static Members

isAvailable()

Checks if SafariViewController is available

Returns: Promise<boolean>

show(options)

Shows Safari View Controller

Param Type Details
options SafariViewControllerOptions

optional

Returns: Promise<any>

hide()

Hides Safari View Controller

connectToService()

Tries to connect to the Chrome’s custom tabs service. you must call this method before calling any of the other methods listed below.

Returns: Promise<any>

warmUp()

Call this method whenever there’s a chance the user will open an external url.

Returns: Promise<any>

mayLaunchUrl(url)

For even better performance optimization, call this methods if there’s more than a 50% chance the user will open a certain URL.

Param Type Details
url string

Returns: Promise<any>

SafariViewControllerOptions

Param Type Details
url
(optional)
string
hidden
(optional)
boolean
toolbarColor
(optional)
string
animated
(optional)
boolean
showDefaultShareMenuItem
(optional)
boolean
enterReaderModeIfAvailable
(optional)
boolean
tintColor
(optional)
string
transition
(optional)
string

API

Native

General