2016-06-09 22:05:38 +08:00
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name SafariViewController
|
|
|
|
* @description
|
|
|
|
* @usage
|
|
|
|
* ```
|
|
|
|
* import {SafariViewController} from 'ionic-native';
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
* SafariViewController.isAvailable()
|
|
|
|
* .then(
|
|
|
|
* (available) => {
|
|
|
|
* if(available){
|
|
|
|
*
|
|
|
|
* SafariViewController.show({
|
2016-06-10 09:18:13 +08:00
|
|
|
* url: 'http://ionic.io',
|
2016-06-09 22:05:38 +08:00
|
|
|
* 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
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* );
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
plugin: 'cordova-plugin-safariviewcontroller',
|
|
|
|
pluginRef: 'SafariViewController',
|
|
|
|
platforms: ['iOS'],
|
|
|
|
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller'
|
|
|
|
})
|
|
|
|
export class SafariViewController {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if SafariViewController is available
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static isAvailable(): Promise<boolean> {return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows Safari View Controller
|
|
|
|
* @param options
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
callbackOrder: 'reverse'
|
|
|
|
})
|
2016-06-16 17:06:54 +08:00
|
|
|
static show(options?: SafariViewControllerOptions): Promise<any> {return; }
|
2016-06-09 22:05:38 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides Safari View Controller
|
|
|
|
*/
|
|
|
|
@Cordova({
|
|
|
|
sync: true
|
|
|
|
})
|
|
|
|
static hide(): void {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to connect to the Chrome's custom tabs service. you must call this method before calling any of the other methods listed below.
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static connectToService(): Promise<any> {return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Call this method whenever there's a chance the user will open an external url.
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static warmUp(): Promise<any> {return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* For even better performance optimization, call this methods if there's more than a 50% chance the user will open a certain URL.
|
|
|
|
* @param url
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static mayLaunchUrl(url: string): Promise<any> {return; }
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface SafariViewControllerOptions {
|
|
|
|
url?: string;
|
|
|
|
hidden?: boolean;
|
|
|
|
toolbarColor?: string;
|
|
|
|
animated?: boolean;
|
|
|
|
showDefaultShareMenuItem?: boolean;
|
|
|
|
enterReaderModeIfAvailable?: boolean;
|
|
|
|
tintColor?: string;
|
|
|
|
transition?: string;
|
2016-06-16 17:06:54 +08:00
|
|
|
}
|