From dd39ba8c485557f39191d3d7f885cc8cde4d8ad9 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Fri, 26 Aug 2016 10:16:20 +0100 Subject: [PATCH] feat(IsDebug): add the IsDebug plugin (#475) --- src/index.ts | 2 ++ src/plugins/is-debug.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/plugins/is-debug.ts diff --git a/src/index.ts b/src/index.ts index 774886ee..5872852d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -53,6 +53,7 @@ import { ImageResizer } from './plugins/imageresizer'; import { InAppBrowser } from './plugins/inappbrowser'; import { Insomnia } from './plugins/insomnia'; import { Instagram } from './plugins/instagram'; +import { IsDebug } from './plugins/is-debug'; import { Keyboard } from './plugins/keyboard'; import { LaunchNavigator } from './plugins/launchnavigator'; import { LocalNotifications } from './plugins/localnotifications'; @@ -228,6 +229,7 @@ window['IonicNative'] = { ImageResizer: ImageResizer, InAppBrowser: InAppBrowser, Instagram: Instagram, + IsDebug: IsDebug, Keyboard: Keyboard, LaunchNavigator: LaunchNavigator, LocalNotifications: LocalNotifications, diff --git a/src/plugins/is-debug.ts b/src/plugins/is-debug.ts new file mode 100644 index 00000000..af478722 --- /dev/null +++ b/src/plugins/is-debug.ts @@ -0,0 +1,35 @@ +import {Plugin, Cordova} from './plugin'; + +/** + * @name IsDebug + * @description + * Detect if the app is running in debug mode or not. + * Debug mode is when the app is built and installed locally via xcode / eclipse / the cordova cli etc, compared to release mode when the app was downloaded from the app / play store via an end user. + * + * @usage + * ``` + * import {IsDebug} from 'ionic-native'; + * + * IsDebug.getIsDebug() + * .then((isDebug: boolean) => console.log('Is debug:', isDebug)) + * .catch((error: any) => console.error(error)); + * + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-is-debug', + pluginRef: 'cordova.plugins.IsDebug', + repo: 'https://github.com/mattlewis92/cordova-plugin-is-debug' +}) +export class IsDebug { + + /** + * Determine if an app was installed via xcode / eclipse / the ionic CLI etc + * @return {Promise} Returns a promise that resolves with true if the app was installed via xcode / eclipse / the ionic CLI etc. It will resolve to false if the app was downloaded from the app / play store by the end user. + */ + @Cordova() + static getIsDebug(): Promise { + return; + } + +}