mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-04-13 00:00:10 +08:00
328e5de3f3
* added platforms * round 2 * round 3 * Update index.ts
114 lines
3.0 KiB
TypeScript
114 lines
3.0 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core';
|
|
|
|
export interface SafariViewControllerOptions {
|
|
animated?: boolean;
|
|
barColor?: string;
|
|
controlTintColor?: string;
|
|
enterReaderModeIfAvailable?: boolean;
|
|
hidden?: boolean;
|
|
showDefaultShareMenuItem?: boolean;
|
|
tintColor?: string;
|
|
toolbarColor?: string;
|
|
transition?: string;
|
|
url?: string;
|
|
}
|
|
|
|
/**
|
|
* @name Safari View Controller
|
|
* @description
|
|
* @usage
|
|
* ```typescript
|
|
* import { SafariViewController } from '@ionic-native/safari-view-controller';
|
|
*
|
|
* constructor(private safariViewController: SafariViewController) { }
|
|
*
|
|
* ...
|
|
*
|
|
* this.safariViewController.isAvailable()
|
|
* .then((available: boolean) => {
|
|
* if (available) {
|
|
*
|
|
* this.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
|
|
* }
|
|
* }
|
|
* );
|
|
* ```
|
|
* @interfaces
|
|
* SafariViewControllerOptions
|
|
*/
|
|
@Plugin({
|
|
pluginName: 'SafariViewController',
|
|
plugin: 'cordova-plugin-safariviewcontroller',
|
|
pluginRef: 'SafariViewController',
|
|
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller',
|
|
platforms: ['Android', 'iOS']
|
|
})
|
|
@Injectable()
|
|
export class SafariViewController extends IonicNativePlugin {
|
|
|
|
/**
|
|
* Checks if SafariViewController is available
|
|
* @returns {Promise<boolean>}
|
|
*/
|
|
@Cordova()
|
|
isAvailable(): Promise<boolean> { return; }
|
|
|
|
/**
|
|
* Shows Safari View Controller
|
|
* @param options {SafariViewControllerOptions} optional
|
|
* @returns {Promise<any>}
|
|
*/
|
|
@Cordova({
|
|
successIndex: 1,
|
|
errorIndex: 2
|
|
})
|
|
show(options?: SafariViewControllerOptions): Promise<any> { return; }
|
|
|
|
/**
|
|
* Hides Safari View Controller
|
|
*/
|
|
@Cordova()
|
|
hide(): Promise<any> { return; }
|
|
|
|
/**
|
|
* 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>}
|
|
*/
|
|
@Cordova()
|
|
connectToService(): Promise<any> { return; }
|
|
|
|
/**
|
|
* Call this method whenever there's a chance the user will open an external url.
|
|
* @returns {Promise<any>}
|
|
*/
|
|
@Cordova()
|
|
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{string}
|
|
* @returns {Promise<any>}
|
|
*/
|
|
@Cordova()
|
|
mayLaunchUrl(url: string): Promise<any> { return; }
|
|
|
|
}
|