-
Notifications
You must be signed in to change notification settings - Fork 144
Home
Welcome to the cordova-plugin-safariviewcontroller wiki!
If you liked this plugin, we invite you to check out its new (experimental) android side, powered by Chrome custom tabs. Please note that this part of the plugin is not stable, so API may change in the future
-
In Android Studio: open the SDK manager, then go to the 'SDK Tools' tab, and check 'Android Support Repository' (You only need to do it once per machine, it's also available via CLI if you don't use Android Studio).
-
Install the master version of the plugin
cordova plugin add --save https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller
As a rule of thumb, The API is meant to be equal to the iOS version of the plugin as much as possible
isAvailable(callback)
just like in the iOS version of the plugin.
As in iOS it accepts an options object and a success and fail callbacks.
show({options}, successCallback, failCallback)
-
url
- String, required. -
toolbarColor
- String, default: light gray. Supported formats are: #RRGGBB #AARRGGBB or a named color (full list). -
animated
- Boolean, default: true. -
transition
- String, default: "slide" (it's also the only animation available at the moment) The browser window will slide in from the right. -
showDefaultShareMenuItem
(default false) - if set to true, will add a menu entry to share the current URL.
any other option will be ignored.
successCallback(data)
may be called once when the tab is loaded and once when it is closed.
an object with one property: event
that describes what happened is supplied (equals to either 'loaded'
or 'closed'
).
You can get better performance if you will call warmUp
and mayLaunchUrl
before the call to show
(see below).
but don't forget to read through the Best practices section
errorCallback(error)
is called when someting went wrong.
connectToService(successCallback, failCallback)
- trying to connect to the Chrome's custom tabs service. you must call this method before calling any of the other methods listed below.
warmUp(successCallback, failCallback)
- call this method whenever there's a chance the user will open an external url.
mayLaunchUrl(url, success, fail)
- for even better performance optimization, call this methods if there's more than a 50% chance the user will open a certain URL.