(feat) added cordova-plugin-browsertab support

This commit is contained in:
mru 2017-02-21 15:00:48 +01:00
parent ba0f6ec6e5
commit 00eb5cf5d8
2 changed files with 61 additions and 1 deletions

View File

@ -8,8 +8,8 @@ import { ActionSheet } from './plugins/actionsheet';
import { AdMob } from './plugins/admob';
import { AndroidFingerprintAuth } from './plugins/android-fingerprint-auth';
import { AppAvailability } from './plugins/appavailability';
import { AppRate } from './plugins/apprate';
import { AppPreferences } from './plugins/apppreferences';
import { AppRate } from './plugins/apprate';
import { AppVersion } from './plugins/appversion';
import { Badge } from './plugins/badge';
import { BackgroundGeolocation } from './plugins/background-geolocation';
@ -22,6 +22,7 @@ import { Brightness } from './plugins/brightness';
import { BLE } from './plugins/ble';
import { BluetoothSerial } from './plugins/bluetoothserial';
import { Broadcaster } from './plugins/broadcaster';
import { BrowserTab } from './plugins/browser-tab';
import { Calendar } from './plugins/calendar';
import { CallNumber } from './plugins/call-number';
import { Camera } from './plugins/camera';
@ -145,6 +146,7 @@ export * from './plugins/ble';
export * from './plugins/bluetoothserial';
export * from './plugins/brightness';
export * from './plugins/broadcaster';
export * from './plugins/browser-tab';
export * from './plugins/calendar';
export * from './plugins/call-number';
export * from './plugins/camera';
@ -270,6 +272,7 @@ window['IonicNative'] = {
BLE,
BluetoothSerial,
Broadcaster,
BrowserTab,
Calendar,
CallNumber,
Camera,

View File

@ -0,0 +1,57 @@
import { Plugin, Cordova } from './plugin';
/**
* @name BrowserTab
* @description
* This plugin opens a new tab in the system prefered browser
*
* @usage
* ```
* import { BrowserTab } from 'ionic-native';
*
* const URL = 'http://ionicframework.com/docs/'
*
* BrowserTab.isAvailable()
* .then((result) => {
* console.log('BrowserTab is available');
*
* BrowserTab.openUrl(URL).catch((error) => { console.log(error); });
*
* }).catch((error) => {
* console.log('BrowserTab is not available');
* });
*
*
* ```
*/
@Plugin({
pluginName: 'BrowserTab',
plugin: 'cordova-plugin-browsertab', // npm package name, example: cordova-plugin-camera
pluginRef: 'cordova.plugins.browsertab', // the variable reference to call the plugin, example: navigator.geolocation
repo: 'https://github.com/google/cordova-plugin-browsertab', // the github repository URL for the plugin
})
export class BrowserTab {
/**
* This function test if browserTab is available or not
* @return {Promise<any>} Returns a promise
*/
@Cordova()
static isAvailable(): Promise<any> { return; }
/**
* This function opens a new tab in the system default browser
* @param url {string} URL to open
* @return {Promise<any>} Returns a promise
*/
@Cordova()
static openUrl(url: string): Promise<any> { return; }
/**
* This function closes a tab
* @return {Promise<any>} Returns a promise
*/
@Cordova()
static close(): Promise<any> { return; }
}