From 00eb5cf5d8aaac9d798f9d8450e0f35f57ffb52a Mon Sep 17 00:00:00 2001 From: mru Date: Tue, 21 Feb 2017 15:00:48 +0100 Subject: [PATCH] (feat) added cordova-plugin-browsertab support --- src/index.ts | 5 +++- src/plugins/browser-tab.ts | 57 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/plugins/browser-tab.ts diff --git a/src/index.ts b/src/index.ts index bcf14402e8..fe4f0b3025 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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, diff --git a/src/plugins/browser-tab.ts b/src/plugins/browser-tab.ts new file mode 100644 index 0000000000..ddd2c00143 --- /dev/null +++ b/src/plugins/browser-tab.ts @@ -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} Returns a promise + */ + @Cordova() + static isAvailable(): Promise { return; } + + /** + * This function opens a new tab in the system default browser + * @param url {string} URL to open + * @return {Promise} Returns a promise + */ + @Cordova() + static openUrl(url: string): Promise { return; } + + /** + * This function closes a tab + * @return {Promise} Returns a promise + */ + @Cordova() + static close(): Promise { return; } + +}