diff --git a/CHANGELOG.md b/CHANGELOG.md index ad87e29b6..0ab3837d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,107 @@ + +# [2.8.0](https://github.com/driftyco/ionic-native/compare/v2.7.0...v2.8.0) (2017-03-04) + + +### Bug Fixes + +* **file:** fix return types ([b458327](https://github.com/driftyco/ionic-native/commit/b458327)), closes [#1139](https://github.com/driftyco/ionic-native/issues/1139) + + +### Features + +* **app-preferences:** added cordova-plugin-app-preferences support ([#1084](https://github.com/driftyco/ionic-native/issues/1084)) ([12280dd](https://github.com/driftyco/ionic-native/commit/12280dd)) +* **health:** add wrapper for cordova-plugin-health ([#1039](https://github.com/driftyco/ionic-native/issues/1039)) ([3500d80](https://github.com/driftyco/ionic-native/commit/3500d80)) +* **photo-library:** added cordova-plugin-photo-library ([#1102](https://github.com/driftyco/ionic-native/issues/1102)) ([384dfc2](https://github.com/driftyco/ionic-native/commit/384dfc2)) + + + + +# [2.7.0](https://github.com/driftyco/ionic-native/compare/v2.6.0...v2.7.0) (2017-03-02) + + +### Bug Fixes + +* **core:** dont check if method exists when overriding ([754c5ec](https://github.com/driftyco/ionic-native/commit/754c5ec)), closes [#1043](https://github.com/driftyco/ionic-native/issues/1043) +* **file:** fix writeExistingFile ([47f48ba](https://github.com/driftyco/ionic-native/commit/47f48ba)), closes [#1044](https://github.com/driftyco/ionic-native/issues/1044) + + +### Features + +* **background-mode:** add missing functions ([906401b](https://github.com/driftyco/ionic-native/commit/906401b)), closes [#1078](https://github.com/driftyco/ionic-native/issues/1078) +* **background-mode:** replace event listeners with on method ([ffdbab7](https://github.com/driftyco/ionic-native/commit/ffdbab7)) +* **diagnostic:** add new methods ([5144345](https://github.com/driftyco/ionic-native/commit/5144345)), closes [#1045](https://github.com/driftyco/ionic-native/issues/1045) + + + + +# [2.6.0](https://github.com/driftyco/ionic-native/compare/v2.5.1...v2.6.0) (2017-03-02) + + +### Bug Fixes + +* **apprate:** add missing Windows Store option ([#1072](https://github.com/driftyco/ionic-native/issues/1072)) ([439ccee](https://github.com/driftyco/ionic-native/commit/439ccee)) +* **background-geolocation:** configure returns a promise ([fc87992](https://github.com/driftyco/ionic-native/commit/fc87992)), closes [#1118](https://github.com/driftyco/ionic-native/issues/1118) +* **contacts:** allow passing asterisk as contact field type ([9c5b593](https://github.com/driftyco/ionic-native/commit/9c5b593)), closes [#1093](https://github.com/driftyco/ionic-native/issues/1093) +* **contacts:** allow passing asterisk as contact field type ([2639486](https://github.com/driftyco/ionic-native/commit/2639486)) +* **facebook:** fixes issue when not supplying default params ([#1088](https://github.com/driftyco/ionic-native/issues/1088)) ([85a3a40](https://github.com/driftyco/ionic-native/commit/85a3a40)) +* **file:** add missing exports ([#1101](https://github.com/driftyco/ionic-native/issues/1101)) ([23b97f6](https://github.com/driftyco/ionic-native/commit/23b97f6)) +* **file:** platform Browser will raise a an DOMException ([#1082](https://github.com/driftyco/ionic-native/issues/1082)) ([2fba915](https://github.com/driftyco/ionic-native/commit/2fba915)) +* **file:** remove FileError from return type ([#1086](https://github.com/driftyco/ionic-native/issues/1086)) ([c1748bb](https://github.com/driftyco/ionic-native/commit/c1748bb)) +* **imagepicker:** add outputType option ([#1098](https://github.com/driftyco/ionic-native/issues/1098)) ([b4b7cfa](https://github.com/driftyco/ionic-native/commit/b4b7cfa)) +* **media:** add missing pauseRecord and resumeRecord methods ([#1122](https://github.com/driftyco/ionic-native/issues/1122)) ([234ed6e](https://github.com/driftyco/ionic-native/commit/234ed6e)) +* **plugin:** revert changes to support stable version ([#1116](https://github.com/driftyco/ionic-native/issues/1116)) ([104532e](https://github.com/driftyco/ionic-native/commit/104532e)), closes [#1001](https://github.com/driftyco/ionic-native/issues/1001) +* **push:** add the missing option clearBadge ([#1087](https://github.com/driftyco/ionic-native/issues/1087)) ([70847d1](https://github.com/driftyco/ionic-native/commit/70847d1)) +* **serial:** Serial.requestPermission() options are optional ([#1128](https://github.com/driftyco/ionic-native/issues/1128)) ([da72500](https://github.com/driftyco/ionic-native/commit/da72500)) +* **zip:** progress callback is optional ([#1049](https://github.com/driftyco/ionic-native/issues/1049)) ([83f57b9](https://github.com/driftyco/ionic-native/commit/83f57b9)) + + +### Features + +* **alipay:** add alipay support. ([#1097](https://github.com/driftyco/ionic-native/issues/1097)) ([2eea3df](https://github.com/driftyco/ionic-native/commit/2eea3df)) +* **app-update:** add cordova-plugin-app-update support ([#1105](https://github.com/driftyco/ionic-native/issues/1105)) ([21d4088](https://github.com/driftyco/ionic-native/commit/21d4088)) +* **appodeal:** adds Appodeal SDK wrappers for iOS and Android ([#1031](https://github.com/driftyco/ionic-native/issues/1031)) ([fd8107b](https://github.com/driftyco/ionic-native/commit/fd8107b)) +* **background-fetch:** Adding Background Fetch requested in [#990](https://github.com/driftyco/ionic-native/issues/990) ([#1013](https://github.com/driftyco/ionic-native/issues/1013)) ([57e2691](https://github.com/driftyco/ionic-native/commit/57e2691)) +* **browser-tab:** add browser tab plugin ([#1126](https://github.com/driftyco/ionic-native/issues/1126)) ([8de3793](https://github.com/driftyco/ionic-native/commit/8de3793)), closes [#1115](https://github.com/driftyco/ionic-native/issues/1115) +* **couchbase-lite:** add CouchbaseLite cordova plugin ([#1025](https://github.com/driftyco/ionic-native/issues/1025)) ([09a7dcf](https://github.com/driftyco/ionic-native/commit/09a7dcf)) +* **file:** add system paths ([f0e2195](https://github.com/driftyco/ionic-native/commit/f0e2195)) +* **google-maps:** add constant for map type ([318ad3f](https://github.com/driftyco/ionic-native/commit/318ad3f)) +* **gyroscope:** add Gyroscope plugin ([#1004](https://github.com/driftyco/ionic-native/issues/1004)) ([0378b1d](https://github.com/driftyco/ionic-native/commit/0378b1d)) +* **inappbrowser:** add interface for IAB options ([#1065](https://github.com/driftyco/ionic-native/issues/1065)) ([f4b8236](https://github.com/driftyco/ionic-native/commit/f4b8236)) +* **local-notifications:** support for icon background color ([#1079](https://github.com/driftyco/ionic-native/issues/1079)) ([2a32624](https://github.com/driftyco/ionic-native/commit/2a32624)) +* **text-to-speech:** Add stop method ([#1063](https://github.com/driftyco/ionic-native/issues/1063)) ([4f86320](https://github.com/driftyco/ionic-native/commit/4f86320)) +* **unique-device-add:** add UniqueDeviceId plugin ([#1064](https://github.com/driftyco/ionic-native/issues/1064)) ([60db10c](https://github.com/driftyco/ionic-native/commit/60db10c)) + + + + +## [2.5.1](https://github.com/driftyco/ionic-native/compare/v2.5.0...v2.5.1) (2017-02-07) + + +### Bug Fixes + +* **pin-dialog:** add missing errorIndex ([b7701cd](https://github.com/driftyco/ionic-native/commit/b7701cd)) + + + + +# [2.5.0](https://github.com/driftyco/ionic-native/compare/v2.4.1...v2.5.0) (2017-02-07) + + +### Bug Fixes + +* **file-transfer:** fix return type of upload method ([a5b4632](https://github.com/driftyco/ionic-native/commit/a5b4632)), closes [#1002](https://github.com/driftyco/ionic-native/issues/1002) +* **pinterest:** fix PinterestPin interface ([a03afcf](https://github.com/driftyco/ionic-native/commit/a03afcf)) +* **safari-view-controller:** fix issue caused by calling show without options ([dc37d8f](https://github.com/driftyco/ionic-native/commit/dc37d8f)) + + +### Features + +* **background-geolocation:** add missing properties for Android ([f0cf860](https://github.com/driftyco/ionic-native/commit/f0cf860)) +* **barcodescanner:** add option disableSuccessBeep ([#1035](https://github.com/driftyco/ionic-native/issues/1035)) ([97489ba](https://github.com/driftyco/ionic-native/commit/97489ba)) +* **inappbrowser:** add hide function ([#1018](https://github.com/driftyco/ionic-native/issues/1018)) ([4ab87d8](https://github.com/driftyco/ionic-native/commit/4ab87d8)) + + + ## [2.4.1](https://github.com/driftyco/ionic-native/compare/v2.4.0...v2.4.1) (2017-01-24) diff --git a/src/@ionic-native/core/plugin.ts b/src/@ionic-native/core/plugin.ts index cc0b63bfb..2aaac517b 100644 --- a/src/@ionic-native/core/plugin.ts +++ b/src/@ionic-native/core/plugin.ts @@ -374,14 +374,6 @@ function overrideFunction(pluginObj: any, methodName: string, args: any[], opts: return; } - let method = pluginInstance[methodName]; - if (!method) { - observer.error({ - error: 'no_such_method' - }); - observer.complete(); - return; - } pluginInstance[methodName] = observer.next.bind(observer); }); } @@ -572,3 +564,52 @@ export function CordovaFunctionOverride(opts: any = {}) { }; }; } + +/** + * @private + */ +export interface CordovaFiniteObservableOptions extends CordovaOptions { + /** + * Function that gets a result returned from plugin's success callback, and decides whether it is last value and observable should complete. + */ + resultFinalPredicate?: (result: any) => boolean; + /** + * Function that gets called after resultFinalPredicate, and removes service data that indicates end of stream from the result. + */ + resultTransform?: (result: any) => any; +} + +/** + * @private + * + * Wraps method that returns an observable that can be completed. Provided opts.resultFinalPredicate dictates when the observable completes. + * + */ +export function CordovaFiniteObservable(opts: CordovaFiniteObservableOptions = {}) { + if (opts.observable === false) { + throw new Error('CordovaFiniteObservable decorator can only be used on methods that returns observable. Please provide correct option.'); + } + opts.observable = true; + return (target: Object, methodName: string, descriptor: TypedPropertyDescriptor) => { + return { + value: function(...args: any[]) { + let wrappedObservable: Observable = wrap(this, methodName, opts).apply(this, args); + return new Observable((observer) => { + let wrappedSubscription = wrappedObservable.subscribe({ + next: (x) => { + observer.next(opts.resultTransform ? opts.resultTransform(x) : x); + if (opts.resultFinalPredicate && opts.resultFinalPredicate(x)) { + observer.complete(); + } + }, + error: (err) => { observer.error(err); }, + complete: () => { observer.complete(); } + }); + return () => { + wrappedSubscription.unsubscribe(); + }; + }); + } + }; + }; +} diff --git a/src/@ionic-native/plugins/alipay/index.ts b/src/@ionic-native/plugins/alipay/index.ts new file mode 100644 index 000000000..939ddcd31 --- /dev/null +++ b/src/@ionic-native/plugins/alipay/index.ts @@ -0,0 +1,118 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @private + */ +export interface AlipayOrder { + /** + * appId assigned by Alipay + */ + app_id: string; + + /** + * Api name. + * Should be: alipay.trade.app.pay + */ + method: string; + + /** + * Data format + * Default: "JSON" + */ + format?: string; + + /** + * Charset + * Possible values: "UTF-8", "GBK" + * Default: "UTF-8" + */ + charset: string; + + /** + * Sign method + * Default: 'RSA' + */ + sign_type: string; + + /** + * Sign value. Should be got from server side. + * Default: 'RSA' + */ + sign: string; + + /** + * Timestamp, formated like "yyyy-MM-dd HH:mm:ss", e.g. 2014-07-24 03:07:50 + */ + timestamp: string; + + /** + * Api version. Fixed value '1.0' + */ + version: string; + + /** + * Notify url. + */ + notify_url: string; + + /** + * biz content. formated in json. see alipay doc for detail. + */ + biz_content: string; +} + +/** + * @name Alipay + * @description + * This plugin is used for Alipay APP support. Integrated with the latest SDK. + * + * Requires Cordova plugin: `cordova-alipay-base`. For more info, please see the [Alipay plugin docs](https://github.com/xueron/cordova-alipay-base). + * + * @usage + * ``` + * import { Alipay, AlipayOrder } from '@ionic-native/alipay'; + * + * constructor(private alipay: Alipay) { + * + * // Should get from server side with sign. + * const alipayOrder: AlipayOrder = { + * ... + * }; + * + * + * this.alipay.pay(alipayOrder) + * .then(result => { + * console.log(result); // Success + * }) + * .catch(error => { + * console.log(error); // Failed + * }); + * + * } + * + * + * ``` + * + * @interfaces + * AlipayOrder + */ +@Plugin({ + pluginName: 'Alipay', + plugin: 'cordova-alipay-base', + pluginRef: 'Alipay.Base', + repo: 'https://github.com/xueron/cordova-alipay-base', + platforms: ['Android', 'iOS'], + install: 'ionic plugin add https://github.com/xueron/cordova-alipay-base --variable APP_ID=your_app_id' +}) +@Injectable() +export class Alipay { + /** + * Open Alipay to perform App pay + * @param order { AlipayOrder } alipay options + * @returns {Promise} Returns a Promise that resolves with the success return, or rejects with an error. + */ + @Cordova() + pay(order: AlipayOrder): Promise { return; } +} + diff --git a/src/@ionic-native/plugins/app-preferences/index.ts b/src/@ionic-native/plugins/app-preferences/index.ts new file mode 100644 index 000000000..69242fa80 --- /dev/null +++ b/src/@ionic-native/plugins/app-preferences/index.ts @@ -0,0 +1,139 @@ +import { Cordova, Plugin } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; +import { Injectable } from '@angular/core'; + +/** + * @name App Preferences + * @description + * This plugin allows you to read and write app preferences + * + * @usage + * ```typescript + * import { AppPreferences } from '@ionic-native/app-preferences'; + * + * constructor(private appPreferences: AppPreferences) { + * + * this.appPreferences.fetch('key').then((res) => { console.log(res); }); + * + * } + * ``` + * + */ +@Plugin({ + pluginName: 'AppPreferences', + plugin: 'cordova-plugin-app-preferences', // npm package name, example: cordova-plugin-camera + pluginRef: 'plugins.appPreferences', // the variable reference to call the plugin, example: navigator.geolocation + repo: 'https://github.com/apla/me.apla.cordova.app-preferences', // the github repository URL for the plugin +}) +@Injectable() +export class AppPreferences { + + /** + * Get a preference value + * + * @param {string} dict Dictionary for key (OPTIONAL) + * @param {string} key Key + * @return {Promise} Returns a promise + */ + @Cordova({ + sync: true, + callbackOrder: 'reverse' + }) + fetch(dict: string, key?: string): Promise { return; } + + /** + * Set a preference value + * + * @param {string} dict Dictionary for key (OPTIONAL) + * @param {string} key Key + * @param {string} value Value + * @return {Promise} Returns a promise + */ + @Cordova({ + callbackOrder: 'reverse' + }) + store(dict: string, key: string, value?: string): Promise { + return; + } + + /** + * Remove value from preferences + * + * @param {string} dict Dictionary for key (OPTIONAL) + * @param {string} key Key + * @return {Promise} Returns a promise + */ + @Cordova({ + callbackOrder: 'reverse' + }) + remove(dict: string, key?: string): Promise { return; } + + /** + * Clear preferences + * + * @return {Promise} Returns a promise + */ + @Cordova({ + callbackOrder: 'reverse' + }) + clearAll(): Promise { return; } + + /** + * Show native preferences interface + * + * @return {Promise} Returns a promise + */ + @Cordova({ + callbackOrder: 'reverse' + }) + show(): Promise { return; } + + /** + * Show native preferences interface + * + * @param {boolean} subscribe true value to subscribe, false - unsubscribe + * @return {Observable} Returns an observable + */ + @Cordova({ + observable: true + }) + watch(subscribe: boolean): Observable { return; } + + /** + * Return named configuration context + * In iOS you'll get a suite configuration, on Android — named file + * Supports: Android, iOS + * @param {string} suiteName suite name + * @returns {Object} Custom object, bound to that suite + */ + @Cordova({ + platforms: ['Android'] + }) + suite(suiteName: string): Object { return; } + + @Cordova({ + platforms: ['iOS'] + }) + iosSuite(suiteName: string): Object { return; } + + /** + * Return cloud synchronized configuration context + * Currently supports Windows and iOS/macOS + * @returns {Object} Custom object, bound to that suite + */ + @Cordova({ + platforms: ['iOS', 'Windows', 'Windows Phone 8'] + }) + cloudSync(): Object { return; } + + /** + * Return default configuration context + * Currently supports Windows and iOS/macOS + * @returns {Object} Custom Object, bound to that suite + */ + @Cordova({ + platforms: ['iOS', 'Windows', 'Windows Phone 8'] + }) + defaults(): Object { return; } + +} diff --git a/src/@ionic-native/plugins/app-rate/index.ts b/src/@ionic-native/plugins/app-rate/index.ts index 088671cc3..8491e6384 100644 --- a/src/@ionic-native/plugins/app-rate/index.ts +++ b/src/@ionic-native/plugins/app-rate/index.ts @@ -79,6 +79,11 @@ export interface AppUrls { */ android?: string; + /** + * application URL in Windows Store + */ + windows?: string; + /** * application URL in AppWorld */ @@ -105,6 +110,7 @@ export interface AppUrls { * AppRate.preferences.storeAppURL = { * ios: '', * android: 'market://details?id=', + * windows: 'ms-windows-store://review/?ProductId=' * }; * * AppRate.promptForRating(false); @@ -121,7 +127,7 @@ export interface AppUrls { plugin: 'cordova-plugin-apprate', pluginRef: 'AppRate', repo: 'https://github.com/pushandplay/cordova-plugin-apprate', - platforms: ['Android', 'iOS'] + platforms: ['Android', 'iOS', 'Windows (experimental)'] }) @Injectable() export class AppRate { diff --git a/src/@ionic-native/plugins/app-update/index.ts b/src/@ionic-native/plugins/app-update/index.ts new file mode 100644 index 000000000..05e4080f8 --- /dev/null +++ b/src/@ionic-native/plugins/app-update/index.ts @@ -0,0 +1,56 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @name App Update + * @description + * This plugin does self-update for android + * + * @usage + * + * You should first host an XML file on your server with the following data in it: + * ```xml + * + * 302048 + * APK Name + * https://your-remote-api.com/YourApp.apk + * + * ``` + * + * Then use the following code: + * + * ``` + * import { AppUpdate } from '@ionic-native/app-update'; + * + * constructor(private appUpdate: AppUpdate) { + * + * const updateUrl = 'http://your-remote-api.com/update.xml'; + * this.appUpdate.checkAppUpdate(updateUrl); + * + * } + * + * + * ``` + * + * The plugin will compare the app version and update it automatically if the API has a newer version to install. + */ +@Plugin({ + pluginName: 'AppUpdate', + plugin: 'cordova-plugin-app-update', + pluginRef: 'AppUpdate', + repo: 'https://github.com/vaenow/cordova-plugin-app-update', + platforms: ['Android'] +}) +@Injectable() +export class AppUpdate { + /** + * Check and update + * @param updateUrl {string} update api url + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova({ + callbackOrder: 'reverse' + }) + checkAppUpdate(updateUrl: string): Promise { return; } +} + diff --git a/src/@ionic-native/plugins/appodeal/index.ts b/src/@ionic-native/plugins/appodeal/index.ts new file mode 100644 index 000000000..37c41ff27 --- /dev/null +++ b/src/@ionic-native/plugins/appodeal/index.ts @@ -0,0 +1,519 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Observable } from 'rxjs'; +import { Injectable } from '@angular/core'; + +/** + * @name Appodeal + * @description + * Plugin to serve ads through native Appodeal SDKs + * + * @usage + * ``` + * import { Appodeal } from '@ionic-native/appodeal'; + * + * constructor(private appodeal: Appodeal) { + * + * const appKey = ''; + * appodeal.initialize(appKey, appodeal.AD_TYPES.REWARDED_VIDEO); + * appodeal.show(appodeal.AD_TYPES.REWARDED_VIDEO); + * + * } + * + * + * + * ``` + */ +@Plugin({ + pluginName: 'Appodeal', + plugin: 'https://github.com/appodeal/appodeal-cordova-plugin', + pluginRef: 'Appodeal', + repo: 'https://github.com/appodeal/appodeal-cordova-plugin.git', + platforms: [ 'ios', 'android' ] +}) +@Injectable() +export class Appodeal { + // available types of advertisements + readonly AD_TYPES = { + INTERSTITIAL: 1, + SKIPPABLE_VIDEO: 2, + BANNER: 4, + BANNER_BOTTOM: 8, + BANNER_TOP: 16, + REWARDED_VIDEO: 128, + NON_SKIPPABLE_VIDEO: 256 + }; + + /** + * initialize Appodeal SDK + * @param {string} appKey + * @param {number} adType + */ + @Cordova() + initialize(appKey: string, adType: number): void {}; + + /** + * check if SDK has been initialized + * @returns {Promise} + */ + @Cordova() + isInitialized(): Promise { return; }; + + /** + * show ad of specified type + * @param {number} adType + * @returns {Promise} + */ + @Cordova() + show(adType: number): Promise { return; }; + + /** + * show ad of specified type with placement options + * @param {number} adType + * @param {any} placement + * @returns {Promise} + */ + @Cordova() + showWithPlacement( + adType: number, + placement: any + ): Promise { return; }; + + /** + * hide ad of specified type + * @param {number} adType + */ + @Cordova() + hide(adType: number): void {}; + + /** + * confirm use of ads of specified type + * @param {number} adType + */ + @Cordova() + confirm(adType: number): void {}; + + /** + * check if ad of specified type has been loaded + * @param {number} adType + * @returns {Promise} + */ + @Cordova() + isLoaded(adType: number): Promise { return; }; + + /** + * check if ad of specified + * @param {number} adType + * @returns {Promise} + */ + @Cordova() + isPrecache(adType: number): Promise { return; }; + + /** + * + * @param {number} adType + * @param autoCache + */ + @Cordova() + setAutoCache(adType: number, autoCache: any): void {}; + + /** + * forcefully cache an ad by type + * @param {number} adType + */ + @Cordova() + cache(adType: number): void {}; + + /** + * + * @param {boolean} set + */ + @Cordova() + setOnLoadedTriggerBoth(set: boolean): void {}; + + /** + * enable or disable Smart Banners + * @param {boolean} enabled + */ + @Cordova() + setSmartBanners(enabled: boolean): void {}; + + /** + * enable or disable banner backgrounds + * @param {boolean} enabled + */ + @Cordova() + setBannerBackground(enabled: boolean): void {}; + + /** + * enable or disable banner animations + * @param {boolean} enabled + */ + @Cordova() + setBannerAnimation(enabled: boolean): void {}; + + /** + * + * @param value + */ + @Cordova() + set728x90Banners(value: any): void {}; + + /** + * enable or disable logging + * @param {boolean} logging + */ + @Cordova() + setLogging(logging: boolean): void {}; + + /** + * enable or disable testing mode + * @param {boolean} testing + */ + @Cordova() + setTesting(testing: boolean): void {}; + + /** + * reset device ID + */ + @Cordova() + resetUUID(): void {}; + + /** + * get version of Appdeal SDK + */ + @Cordova() + getVersion(): Promise { return; }; + + /** + * + * @param {string} network + * @param {number} adType + */ + @Cordova() + disableNetwork(network?: string, adType?: number): void {}; + + /** + * + * @param {string} network + * @param {number} adType + */ + @Cordova() + disableNetworkType(network?: string, adType?: number): void {}; + + /** + * disable Location permissions for Appodeal SDK + */ + @Cordova() + disableLocationPermissionCheck(): void {}; + + /** + * disable Storage permissions for Appodeal SDK + */ + @Cordova() + disableWriteExternalStoragePermissionCheck(): void {}; + + /** + * enable event listeners + * @param {boolean} enabled + */ + @Cordova() + enableInterstitialCallbacks(enabled: boolean): void {}; + + /** + * enable event listeners + * @param {boolean} enabled + */ + @Cordova() + enableSkippableVideoCallbacks(enabled: boolean): void {}; + + /** + * enable event listeners + * @param {boolean} enabled + */ + @Cordova() + enableNonSkippableVideoCallbacks(enabled: boolean): void {}; + + /** + * enable event listeners + * @param {boolean} enabled + */ + @Cordova() + enableBannerCallbacks(enabled: boolean): void {}; + + /** + * enable event listeners + * @param {boolean} enabled + */ + @Cordova() + enableRewardedVideoCallbacks(enabled: boolean): void {}; + + /** + * + * @param {string} name - name of rule + * @param {boolean} value + */ + @Cordova() + setCustomBooleanRule(name: string, value: boolean): void {}; + + /** + * + * @param {string} name - name of rule + * @param {number} value + */ + @Cordova() + setCustomIntegerRule(name: string, value: number): void {}; + + /** + * set rule with float value + * @param {string} name + * @param {number} value + */ + @Cordova() + setCustomDoubleRule(name: string, value: number): void {}; + + /** + * set rule with string value + * @param {string} name - name of rule + * @param {string} value + */ + @Cordova() + setCustomStringRule(name: string, value: string): void {}; + + /** + * set ID preference in Appodeal for current user + * @param id + */ + @Cordova() + setUserId(id: any): void {}; + + /** + * set Email preference in Appodeal for current user + * @param email + */ + @Cordova() + setEmail(email: any): void {}; + + /** + * set Birthday preference in Appodeal for current user + * @param birthday + */ + @Cordova() + setBirthday(birthday: any): void {}; + + /** + * et Age preference in Appodeal for current user + * @param age + */ + @Cordova() + setAge(age: any): void {}; + + /** + * set Gender preference in Appodeal for current user + * @param gender + */ + @Cordova() + setGender(gender: any): void {}; + + /** + * set Occupation preference in Appodeal for current user + * @param occupation + */ + @Cordova() + setOccupation(occupation: any): void {}; + + /** + * set Relation preference in Appodeal for current user + * @param relation + */ + @Cordova() + setRelation(relation: any): void {}; + + /** + * set Smoking preference in Appodeal for current user + * @param smoking + */ + @Cordova() + setSmoking(smoking: any): void {}; + + /** + * set Alcohol preference in Appodeal for current user + * @param alcohol + */ + @Cordova() + setAlcohol(alcohol: any): void {}; + + /** + * set Interests preference in Appodeal for current user + * @param interests + */ + @Cordova() + setInterests(interests: any): void {}; + + @Cordova({ + eventObservable: true, + event: 'onInterstitialLoaded', + element: document + }) + onInterstitialLoaded(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onInterstitialFailedToLoad', + element: document + }) + onInterstitialFailedToLoad(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onInterstitialShown', + element: document + }) + onInterstitialShown(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onInterstitialClicked', + element: document + }) + onInterstitialClicked(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onInterstitialClosed', + element: document + }) + onInterstitialClosed(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onSkippableVideoLoaded', + element: document + }) + onSkippableVideoLoaded(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onSkippableVideoFailedToLoad', + element: document + }) + onSkippableVideoFailedToLoad(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onSkippableVideoShown', + element: document + }) + onSkippableVideoShown(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onSkippableVideoFinished', + element: document + }) + onSkippableVideoFinished(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onSkippableVideoClosed', + element: document + }) + onSkippableVideoClosed(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onRewardedVideoLoaded', + element: document + }) + onRewardedVideoLoaded(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onRewardedVideoFailedToLoad', + element: document + }) + onRewardedVideoFailedToLoad(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onRewardedVideoShown', + element: document + }) + onRewardedVideoShown(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onRewardedVideoFinished', + element: document + }) + onRewardedVideoFinished(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onRewardedVideoClosed', + element: document + }) + onRewardedVideoClosed(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onNonSkippableVideoLoaded', + element: document + }) + onNonSkippableVideoLoaded(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onNonSkippableVideoFailedToLoad', + element: document + }) + onNonSkippableVideoFailedToLoad(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onNonSkippableVideoShown', + element: document + }) + onNonSkippableVideoShown(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onNonSkippableVideoFinished', + element: document + }) + onNonSkippableVideoFinished(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onNonSkippableVideoClosed', + element: document + }) + onNonSkippableVideoClosed(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onBannerClicked', + element: document + }) + onBannerClicked(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onBannerFailedToLoad', + element: document + }) + onBannerFailedToLoad(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onBannerLoaded', + element: document + }) + onBannerLoaded(): Observable { return; } + + @Cordova({ + eventObservable: true, + event: 'onBannerShown', + element: document + }) + onBannerShown(): Observable { return; } +} diff --git a/src/@ionic-native/plugins/background-fetch/index.ts b/src/@ionic-native/plugins/background-fetch/index.ts new file mode 100644 index 000000000..d6c3daad4 --- /dev/null +++ b/src/@ionic-native/plugins/background-fetch/index.ts @@ -0,0 +1,106 @@ +import { Cordova, Plugin } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +declare var window; + + +export interface BackgroundFetchConfig { + + /** + * Set true to cease background-fetch from operating after user "closes" the app. Defaults to true. + */ + stopOnTerminate?: boolean; +} + + +/** + * @name Background Fetch + * @description + * iOS Background Fetch Implementation. See: https://developer.apple.com/reference/uikit/uiapplication#1657399 + * iOS Background Fetch is basically an API which wakes up your app about every 15 minutes (during the user's prime-time hours) and provides your app exactly 30s of background running-time. This plugin will execute your provided callbackFn whenever a background-fetch event occurs. There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible value of UIApplicationBackgroundFetchIntervalMinimum -- iOS determines the rate automatically based upon device usage and time-of-day (ie: fetch-rate is about ~15min during prime-time hours; less frequently when the user is presumed to be sleeping, at 3am for example). + * For more detail, please see https://github.com/transistorsoft/cordova-plugin-background-fetch + * + * @usage + * + * ```typescript + * import { BackgroundFetch, BackgroundFetchConfig } from '@ionic-native/background-fetch'; + * + * + * constructor(private backgroundFetch: BackgroundFetch) { + * + * const config: BackgroundFetchConfig = { + * stopOnTerminate: false, // Set true to cease background-fetch from operating after user "closes" the app. Defaults to true. + * }; + * + * backgroundFetch.configure(config) + * .then(() => { + * console.log('Background Fetch initialized'); + * + * this.backgroundFetch.finish(); + * + * }) + * .catch(e => console.log('Error initializing background fetch', e)); + * + * // Start the background-fetch API. Your callbackFn provided to #configure will be executed each time a background-fetch event occurs. NOTE the #configure method automatically calls #start. You do not have to call this method after you #configure the plugin + * backgroundFetch.start(); + * + * // Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed. + * backgroundFetch.stop(); + * + * + * } + * + * ``` + * @interfaces + * BackgroundFetchConfig + * + */ +@Plugin({ + pluginName: 'BackgroundFetch', + plugin: 'cordova-plugin-background-fetch', + pluginRef: 'BackgroundFetch', + repo: 'https://github.com/transistorsoft/cordova-plugin-background-fetch', + platforms: ['iOS'] +}) +@Injectable() +export class BackgroundFetch { + + + /** + * Configures the plugin's fetch callbackFn + * + * @param {BackgroundFetchConfig} config Configuration for plugin + * @return Location object, which tries to mimic w3c Coordinates interface. + * See http://dev.w3.org/geo/api/spec-source.html#coordinates_interface + * Callback to be executed every time a geolocation is recorded in the background. + * @return {Promise} + */ + @Cordova({ + callbackOrder: 'reverse' + }) + configure(config: BackgroundFetchConfig): Promise { return; } + + /** + * Start the background-fetch API. + * Your callbackFn provided to #configure will be executed each time a background-fetch event occurs. NOTE the #configure method automatically calls #start. You do not have to call this method after you #configure the plugin + * @returns {Promise} + */ + @Cordova() + start(): Promise { return; } + + /** + * Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed. + * @returns {Promise} + */ + @Cordova() + stop(): Promise { return; } + + /** + * You MUST call this method in your fetch callbackFn provided to #configure in order to signal to iOS that your fetch action is complete. iOS provides only 30s of background-time for a fetch-event -- if you exceed this 30s, iOS will kill your app. + */ + @Cordova({ + sync: true + }) + finish(): void { } + +} diff --git a/src/@ionic-native/plugins/background-geolocation/index.ts b/src/@ionic-native/plugins/background-geolocation/index.ts index bd6962143..2b147db3a 100644 --- a/src/@ionic-native/plugins/background-geolocation/index.ts +++ b/src/@ionic-native/plugins/background-geolocation/index.ts @@ -365,17 +365,13 @@ export class BackgroundGeolocation { /** * Configure the plugin. * - * @param {Function} callback callback will be called when background location is determined. - * @param {Function} errorCallback callback to be executed every time a geolocation error occurs. - * @param {Config} options An object of type Config - * @return Location object, which tries to mimic w3c Coordinates interface. - * See http://dev.w3.org/geo/api/spec-source.html#coordinates_interface - * Callback to be executed every time a geolocation is recorded in the background. + * @param options {BackgroundGeolocationConfig} options An object of type Config + * @return {Promise} */ @Cordova({ - sync: true + callbackOrder: 'reverse' }) - configure(callback: Function, errorCallback: Function, options: BackgroundGeolocationConfig): any { return; } + configure(options: BackgroundGeolocationConfig): Promise { return; } /** * Turn ON the background-geolocation system. @@ -394,20 +390,26 @@ export class BackgroundGeolocation { /** * Inform the native plugin that you're finished, the background-task may be completed - * NOTE: IOS, WP only + * @returns {Promise} */ - @Cordova() - finish() { } + @Cordova({ + platforms: ['iOS', 'Windows Phone'] + }) + finish(): Promise { return; } /** * Force the plugin to enter "moving" or "stationary" state - * NOTE: IOS, WP only + * @param isMoving {boolean} + * @returns {Promise} */ - @Cordova() - changePace(isMoving: boolean) { } + @Cordova({ + platforms: ['iOS', 'Windows Phone'] + }) + changePace(isMoving: boolean): Promise { return; } /** * Setup configuration + * @param options {BackgroundGeolocationConfig} * @returns {Promise} */ @Cordova({ @@ -417,27 +419,30 @@ export class BackgroundGeolocation { /** * Returns current stationaryLocation if available. null if not - * NOTE: IOS, WP only * @returns {Promise} */ - @Cordova() + @Cordova({ + platforms: ['iOS', 'Windows Phone'] + }) getStationaryLocation(): Promise { return; } /** * Add a stationary-region listener. Whenever the devices enters "stationary-mode", * your #success callback will be executed with #location param containing #radius of region - * NOTE: IOS, WP only * @returns {Promise} */ - @Cordova() + @Cordova({ + platforms: ['iOS', 'Windows Phone'] + }) onStationary(): Promise { return; } /** * Check if location is enabled on the device * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). - * NOTE: ANDROID only */ - @Cordova() + @Cordova({ + platforms: ['Android'] + }) isLocationEnabled(): Promise { return; } /** @@ -456,18 +461,21 @@ export class BackgroundGeolocation { * Method can be used to detect user changes in location services settings. * If user enable or disable location services then success callback will be executed. * In case or error (SettingNotFoundException) fail callback will be executed. - * NOTE: ANDROID only * @returns {Promise} */ - @Cordova() + @Cordova({ + platforms: ['Android'] + }) watchLocationMode(): Promise { return; } /** * Stop watching for location mode changes. - * NOTE: ANDROID only + * @returns {Promise} */ - @Cordova() - stopWatchingLocationMode() { } + @Cordova({ + platforms: ['Android'] + }) + stopWatchingLocationMode(): Promise { return; } /** * Method will return all stored locations. @@ -476,10 +484,11 @@ export class BackgroundGeolocation { * by the system * or * - option.debug is true - * NOTE: ANDROID only * @returns {Promise} */ - @Cordova() + @Cordova({ + platforms: ['Android'] + }) getLocations(): Promise { return; } /**
 @@ -491,18 +500,21 @@ export class BackgroundGeolocation { /** * Delete stored location by given locationId. - * NOTE: ANDROID only + * @param locationId {number} * @returns {Promise} */ - @Cordova() + @Cordova({ + platforms: ['Android'] + }) deleteLocation(locationId: number): Promise { return; } /** * Delete all stored locations. - * NOTE: ANDROID only * @returns {Promise} */ - @Cordova() + @Cordova({ + platforms: ['Android'] + }) deleteAllLocations(): Promise { return; } /** @@ -514,20 +526,20 @@ export class BackgroundGeolocation { * * BackgroundGeolocation.Mode.FOREGROUND * BackgroundGeolocation.Mode.BACKGROUND
 - * - * NOTE: iOS only - * - * @param {number} See above.
 + ** + * @param modeId {number} * @returns {Promise} */ - @Cordova() + @Cordova({ + platforms: ['iOS'] + }) switchMode(modeId: number): Promise { return; } /**
 * Return all logged events. Useful for plugin debugging. Parameter limit limits number of returned entries.
 * @see https://github.com/mauron85/cordova-plugin-background-geolocation/tree/v2.2.1#debugging for more information.
 * - * @param {number} Limits the number of entries
 + * @param limit {number} Limits the number of entries
 * @returns {Promise} */ @Cordova() diff --git a/src/@ionic-native/plugins/background-mode/index.ts b/src/@ionic-native/plugins/background-mode/index.ts index 7240aac15..4808f1ba7 100644 --- a/src/@ionic-native/plugins/background-mode/index.ts +++ b/src/@ionic-native/plugins/background-mode/index.ts @@ -1,6 +1,5 @@ import { Injectable } from '@angular/core'; -import { Cordova, CordovaFunctionOverride, Plugin } from '@ionic-native/core'; - +import { Cordova, Plugin } from '@ionic-native/core'; import { Observable } from 'rxjs/Observable'; @@ -116,24 +115,59 @@ export class BackgroundMode { configure(options?: BackgroundModeConfiguration): Promise { return; } /** - * Called when background mode is activated. - * @returns {Observable} returns an observable that emits when background mode is activated - */ - @CordovaFunctionOverride() - onactivate(): Observable { return; }; + * Listen for events that the plugin fires. Available events are `enable`, `disable`, `activate`, `deactivate` and `failure`. + * @param event {string} Event name + * @returns {Observable} + */ + @Cordova({ + observable: true, + clearFunction: 'un', + clearWithArgs: true + }) + on(event: string): Observable { return; } /** - * Called when background mode is deactivated. - * @returns {Observable} returns an observable that emits when background mode is deactivated - */ - @CordovaFunctionOverride() - ondeactivate(): Observable { return; }; + * Override the back button on Android to go to background instead of closing the app. + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + overrideBackButton(): void {} /** - * Called when background mode fails - * @returns {Observable} returns an observable that emits when background mode fails - */ - @CordovaFunctionOverride() - onfailure(): Observable { return; }; + * Exclude the app from the recent task list works on Android 5.0+. + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + excludeFromTaskList(): void {} + + /** + * The method works async instead of isActive() or isEnabled(). + */ + @Cordova({ + platforms: ['Android'] + }) + isScreenOff(): Promise { return; } + + /** + * Turn screen on + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + wakeUp(): void {} + + /** + * Turn screen on and show app even locked + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + unlock(): void {} } diff --git a/src/@ionic-native/plugins/badge/index.ts b/src/@ionic-native/plugins/badge/index.ts index c6f8ec2ab..916ed8e16 100644 --- a/src/@ionic-native/plugins/badge/index.ts +++ b/src/@ionic-native/plugins/badge/index.ts @@ -15,7 +15,7 @@ import { Cordova, Plugin } from '@ionic-native/core'; * * * Badge.set(10); - * Badge.increase(); + * Badge.increase(1); * Badge.clear(); * ``` */ diff --git a/src/@ionic-native/plugins/browser-tab/index.ts b/src/@ionic-native/plugins/browser-tab/index.ts new file mode 100644 index 000000000..82137b540 --- /dev/null +++ b/src/@ionic-native/plugins/browser-tab/index.ts @@ -0,0 +1,66 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @name BrowserTab + * @description + * This plugin provides an interface to in-app browser tabs that exist on some mobile platforms, specifically [Custom Tabs](http://developer.android.com/tools/support-library/features.html#custom-tabs) on Android (including the [Chrome Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) implementation), and [SFSafariViewController](https://developer.apple.com/library/ios/documentation/SafariServices/Reference/SFSafariViewController_Ref/) on iOS. + * + * @usage + * ``` + * import { BrowserTab } from '@ionic-native/browser-tab'; + * + * constructor(private browserTab: BrowserTab) { + * + * browserTab.isAvailable() + * .then((isAvailable: boolean) => { + * + * if (isAvailable) { + * + * browserTab.open('https://ionic.io'); + * + * } else { + * + * // open URL with InAppBrowser instead or SafariViewController + * + * } + * + * }); + * + * + * } + * + * ``` + */ +@Plugin({ + pluginName: 'BrowserTab', + plugin: 'cordova-plugin-browsertab', + pluginRef: 'cordova.plugins.browsertab', + repo: 'https://github.com/google/cordova-plugin-browsertab', + platforms: ['Android', 'iOS'] +}) +@Injectable() +export class BrowserTab { + + /** + * Check if BrowserTab option is available + * @return {Promise} Returns a promise that resolves when check is successful and returns true or false + */ + @Cordova() + isAvailable(): Promise { return; } + + /** + * Opens the provided URL using a browser tab + * @param {string} url The URL you want to open + * @return {Promise} Returns a promise that resolves when check open was successful + */ + @Cordova() + openUrl(url: string): Promise { return; } + + /** + * Closes browser tab + * @return {Promise} Returns a promise that resolves when close was finished + */ + @Cordova() + close(): Promise { return; } +} diff --git a/src/@ionic-native/plugins/contacts/index.ts b/src/@ionic-native/plugins/contacts/index.ts index 43f6b7eb3..a5c378499 100644 --- a/src/@ionic-native/plugins/contacts/index.ts +++ b/src/@ionic-native/plugins/contacts/index.ts @@ -4,7 +4,7 @@ import { CordovaInstance, InstanceProperty, Plugin, getPromise } from '@ionic-na declare var window: any, navigator: any; -export type ContactFieldType = 'addresses' | 'birthday' | 'categories' | 'country' | 'department' | 'displayName' | 'emails' | 'familyName' | 'formatted' | 'givenName' | 'honorificPrefix' | 'honorificSuffix' | 'id' | 'ims' | 'locality' | 'middleName' | 'name' | 'nickname' | 'note' | 'organizations' | 'phoneNumbers' | 'photos' | 'postalCode' | 'region' | 'streetAddress' | 'title' | 'urls'; +export type ContactFieldType = '*' | 'addresses' | 'birthday' | 'categories' | 'country' | 'department' | 'displayName' | 'emails' | 'familyName' | 'formatted' | 'givenName' | 'honorificPrefix' | 'honorificSuffix' | 'id' | 'ims' | 'locality' | 'middleName' | 'name' | 'nickname' | 'note' | 'organizations' | 'phoneNumbers' | 'photos' | 'postalCode' | 'region' | 'streetAddress' | 'title' | 'urls'; /** * @private diff --git a/src/@ionic-native/plugins/couchbase-lite/index.ts b/src/@ionic-native/plugins/couchbase-lite/index.ts new file mode 100644 index 000000000..dfa14d1d8 --- /dev/null +++ b/src/@ionic-native/plugins/couchbase-lite/index.ts @@ -0,0 +1,42 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + + +/** + * @name Couchbase Lite + * @description + * Plugin to install Couchbase Lite in your PhoneGap app on iOS or Android + * + * @usage + * ``` + * import { CouchbaseLite } from '@ionic-native/couchbase-lite'; + * + * constructor(private couchbase: CouchbaseLite) { + * + * couchbase.getURL() + * .then(url => console.log(url)) + * .catch(error => console.error(error)); + * + * } + * + * ``` + */ +@Plugin({ + pluginName: 'CouchbaseLite', + plugin: 'https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin', + pluginRef: 'cblite', + repo: 'https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin', +}) +@Injectable() +export class CouchbaseLite { + + /** + * Get the database url + * @return {Promise} Returns a promise that resolves with the local database url + */ + @Cordova({ + callbackStyle: 'node' + }) + getURL(): Promise { return; } + +} diff --git a/src/@ionic-native/plugins/device-motion/index.ts b/src/@ionic-native/plugins/device-motion/index.ts index 44ab41ed1..681d01207 100644 --- a/src/@ionic-native/plugins/device-motion/index.ts +++ b/src/@ionic-native/plugins/device-motion/index.ts @@ -42,17 +42,16 @@ export interface DeviceMotionAccelerometerOptions { * * @usage * ```typescript - * import { DeviceMotion } from '@ionic-native/device-motion'; - * + * import { DeviceMotion, DeviceMotionAccelerationData } from '@ionic-native/device-motion'; * * // Get the device current acceleration * DeviceMotion.getCurrentAcceleration().then( - * (acceleration: AccelerationData) => console.log(acceleration), + * (acceleration: DeviceMotionAccelerationData) => console.log(acceleration), * (error: any) => console.log(error) * ); * * // Watch device acceleration - * var subscription = DeviceMotion.watchAcceleration().subscribe((acceleration: AccelerationData) => { + * var subscription = DeviceMotion.watchAcceleration().subscribe((acceleration: DeviceMotionAccelerationData) => { * console.log(acceleration); * }); * diff --git a/src/@ionic-native/plugins/device-orientation/index.ts b/src/@ionic-native/plugins/device-orientation/index.ts index e935410ec..3d293822f 100644 --- a/src/@ionic-native/plugins/device-orientation/index.ts +++ b/src/@ionic-native/plugins/device-orientation/index.ts @@ -47,19 +47,19 @@ export interface DeviceOrientationCompassOptions { * * @usage * ```typescript - * // CompassHeading is an interface for compass - * import { DeviceOrientation, CompassHeading } from '@ionic-native/device-orientation'; + * // DeviceOrientationCompassHeading is an interface for compass + * import { DeviceOrientation, DeviceOrientationCompassHeading } from '@ionic-native/device-orientation'; * * * // Get the device current compass heading * DeviceOrientation.getCurrentHeading().then( - * (data: CompassHeading) => console.log(data), + * (data: DeviceOrientationCompassHeading) => console.log(data), * (error: any) => console.log(error) * ); * * // Watch the device compass heading change * var subscription = DeviceOrientation.watchHeading().subscribe( - * (data: CompassHeading) => console.log(data) + * (data: DeviceOrientationCompassHeading) => console.log(data) * ); * * // Stop watching heading change diff --git a/src/@ionic-native/plugins/diagnostic/index.ts b/src/@ionic-native/plugins/diagnostic/index.ts index b0ecf4046..626537f1f 100644 --- a/src/@ionic-native/plugins/diagnostic/index.ts +++ b/src/@ionic-native/plugins/diagnostic/index.ts @@ -111,6 +111,15 @@ export class Diagnostic { POWERING_ON: 'powering_on' }; + @CordovaProperty + static NFCState: { + UNKNOWN: string; + POWERED_OFF: string; + POWERED_ON: string; + POWERING_ON: string; + POWERING_OFF: string; + }; + /** * Checks if app is able to access device location. @@ -192,6 +201,9 @@ export class Diagnostic { @Cordova({ callbackOrder: 'reverse', platforms: ['Android', 'Windows 10'] }) setBluetoothState(state: boolean): Promise { return; } + + // ANDROID AND IOS ONLY + /** * Returns true if the device setting for location is on. On Android this returns true if Location Mode is switched on. On iOS this returns true if Location Services is switched on. * @returns {Promise} @@ -369,6 +381,9 @@ export class Diagnostic { @Cordova({ platforms: ['Android', 'iOS'], sync: true }) registerLocationStateChangeHandler(handler: Function): void { } + + // ANDROID ONLY + /** * Checks if high-accuracy locations are available to the app from GPS hardware. * Returns true if Location mode is enabled and is set to "Device only" or "High accuracy" AND if the app is authorised to use location. @@ -495,6 +510,96 @@ export class Diagnostic { @Cordova({ platforms: ['Android'] }) hasBluetoothLEPeripheralSupport(): Promise { return; } + /** + * Checks if the application is authorized to use external storage. + * @returns {Promise} + */ + @Cordova({ platforms: ['Android'] }) + static isExternalStorageAuthorized(): Promise { return; } + + /** + * CReturns the external storage authorization status for the application. + * @returns {Promise} + */ + @Cordova({ platforms: ['Android'] }) + static getExternalStorageAuthorizationStatus(): Promise { return; } + + /** + * Requests external storage authorization for the application. + * @returns {Promise} + */ + @Cordova({ platforms: ['Android'] }) + static requestExternalStorageAuthorization(): Promise { return; } + + /** + * Returns details of external SD card(s): absolute path, is writable, free space. + * + * The intention of this method is to return the location and details of removable external SD cards. + * This differs from the "external directories" returned by cordova-plugin-file which return mount points relating to non-removable (internal) storage. + * + * Learn more about this method [here](https://github.com/dpa99c/cordova-diagnostic-plugin#getexternalsdcarddetails) + * + * @returns {Promise} + */ + @Cordova({ platforms: ['Android'] }) + static getExternalSdCardDetails(): Promise { return; } + + /** + * Switches to the wireless settings page in the Settings app. Allows configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks. + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + switchToWirelessSettings(): void { } + + /** + * Displays NFC settings to allow user to enable NFC. + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + switchToNFCSettings(): void { } + + /** + * Checks if NFC hardware is present on device. + * @returns {Promise} + */ + @Cordova({ platforms: ['Android'] }) + static isNFCPresent(): Promise { return; } + + /** + * Checks if the device setting for NFC is switched on. + * Note: this operation does not require NFC permission in the manifest. + * @returns {Promise} + */ + @Cordova({ platforms: ['Android'] }) + static isNFCEnabled(): Promise { return; } + + /** + * Checks if NFC is available to the app. Returns true if the device has NFC capabilities AND if NFC setting is switched on. + * Note: this operation does not require NFC permission in the manifest. + * @returns {Promise} + */ + @Cordova({ platforms: ['Android'] }) + static isNFCAvailable(): Promise { return; } + + /** + * Registers a function to be called when a change in NFC state occurs. Pass in a falsey value to de-register the currently registered function. + * @param hander {Function} callback function to be called when NFC state changes + * @returns {Promise} + */ + @Cordova({ + platforms: ['Android'], + sync: true + }) + registerNFCStateChangeHandler(handler: Function): void { } + + + + // IOS ONLY + /** * Checks if the application is authorized to use the Camera Roll in Photos app. * @returns {Promise} @@ -575,4 +680,40 @@ export class Diagnostic { @Cordova({ platforms: ['iOS'] }) getBackgroundRefreshStatus(): Promise { return; } + /** + * Requests Bluetooth authorization for the application. + * + * Learn more about this method [here](https://github.com/dpa99c/cordova-diagnostic-plugin#requestbluetoothauthorization) + * @return {Promise} + */ + @Cordova({ platforms: ['iOS'] }) + static requestBluetoothAuthorization(): Promise { return; } + + /** + * Checks if motion tracking is available on the current device. + * @return {Promise} + */ + @Cordova({ platforms: ['iOS'] }) + static isMotionAvailable(): Promise { return; } + + /** + * Checks if it's possible to determine the outcome of a motion authorization request on the current device. + * There's no direct way to determine if authorization was granted or denied, so the Pedometer API must be used to indirectly determine this: + * therefore, if the device supports motion tracking but not Pedometer Event Tracking, the outcome of requesting motion detection cannot be determined. + * + * @return {Promise} + */ + @Cordova({ platforms: ['iOS'] }) + static isMotionRequestOutcomeAvailable(): Promise { return; } + + /** + * Requests and checks motion authorization for the application: there is no way to independently request only or check only, so both must be done in one operation. + * + * Learn more about this method [here](https://github.com/dpa99c/cordova-diagnostic-plugin#requestandcheckmotionauthorization) + * + * @return {Promise} + */ + @Cordova({ platforms: ['iOS'] }) + static requestAndCheckMotionAuthorization(): Promise { return; } + } diff --git a/src/@ionic-native/plugins/facebook/index.ts b/src/@ionic-native/plugins/facebook/index.ts index 38c27339e..c2ad8c230 100644 --- a/src/@ionic-native/plugins/facebook/index.ts +++ b/src/@ionic-native/plugins/facebook/index.ts @@ -235,7 +235,10 @@ export class Facebook { * @param {number} [valueToSum] any value to be added to added to a sum on each event * @returns {Promise} */ - @Cordova() + @Cordova({ + successIndex: 3, + errorIndex: 4 + }) logEvent( name: string, params?: Object, diff --git a/src/@ionic-native/plugins/file-chooser/index.ts b/src/@ionic-native/plugins/file-chooser/index.ts index 37588482b..5ff2bcf67 100644 --- a/src/@ionic-native/plugins/file-chooser/index.ts +++ b/src/@ionic-native/plugins/file-chooser/index.ts @@ -12,7 +12,7 @@ import { Plugin, Cordova } from '@ionic-native/core'; * import {FileChooser} from '@ionic-native/file'; * * FileChooser.open() - * .then(uri => console.log(uri)); + * .then(uri => console.log(uri)) * .catch(e => console.log(e)); * * ``` diff --git a/src/@ionic-native/plugins/file/index.ts b/src/@ionic-native/plugins/file/index.ts index fc9b94630..7c50d8f5c 100644 --- a/src/@ionic-native/plugins/file/index.ts +++ b/src/@ionic-native/plugins/file/index.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Plugin, pluginWarn } from '@ionic-native/core'; +import { CordovaProperty, Plugin, pluginWarn } from '@ionic-native/core'; declare var window: any; declare var cordova: any; @@ -172,7 +172,6 @@ export interface Flags { } export interface WriteOptions { - create?: boolean; replace?: boolean; append?: boolean; truncate?: number; // if present, number of bytes to truncate file to before writing @@ -268,7 +267,7 @@ export interface FileWriter extends FileSaver { * Write the supplied data to the file at position. * @param {Blob} data The blob to write. */ - write(data: Blob | string): void; + write(data: ArrayBuffer | Blob | string): void; /** * The file position at which the next write will occur. * @param offset If nonnegative, an absolute byte offset into the file. @@ -284,7 +283,7 @@ export interface FileWriter extends FileSaver { } /* FileWriter states */ -declare var FileWriter: { +export declare var FileWriter: { INIT: number; WRITING: number; DONE: number @@ -309,7 +308,7 @@ export interface FileReader { readAsArrayBuffer(fe: File | Blob): void; } -declare var FileReader: { +export declare var FileReader: { EMPTY: number; LOADING: number; DONE: number; @@ -323,7 +322,7 @@ export interface FileError { message: string; } -declare var FileError: { +export declare var FileError: { new (code: number): FileError; NOT_FOUND_ERR: number; SECURITY_ERR: number; @@ -351,9 +350,7 @@ declare var FileError: { * ``` * import { File } from '@ionic-native/file'; * - * declare var cordova: any; - * const fs:string = cordova.file.dataDirectory; - * this.checkDir(this.fs, 'mydir').then(_ => console.log('yay')).catch(err => console.log('boooh')); + * this.file.checkDir(this.file.dataDirectory, 'mydir').then(_ => console.log('Directory exists')).catch(err => console.log('Directory doesnt exist')); * ``` * * This plugin is based on several specs, including : The HTML5 File API http://www.w3.org/TR/FileAPI/ @@ -369,7 +366,81 @@ declare var FileError: { }) @Injectable() export class File { - static cordovaFileError: {} = { + + /** + * Read-only directory where the application is installed. + */ + @CordovaProperty + applicationDirectory: string; + + /** + * Read-only directory where the application is installed. + */ + @CordovaProperty + applicationStorageDirectory: string; + + /** + * Where to put app-specific data files. + */ + @CordovaProperty + dataDirectory: string; + + /** + * Cached files that should survive app restarts. + * Apps should not rely on the OS to delete files in here. + */ + @CordovaProperty + cacheDirectory: string; + + /** + * Android: the application space on external storage. + */ + @CordovaProperty + externalApplicationStorageDirectory: string; + + /** + * Android: Where to put app-specific data files on external storage. + */ + @CordovaProperty + externalDataDirectory: string; + + /** + * Android: the application cache on external storage. + */ + @CordovaProperty + externalCacheDirectory: string; + + /** + * Android: the external storage (SD card) root. + */ + @CordovaProperty + externalRootDirectory: string; + + /** + * iOS: Temp directory that the OS can clear at will. + */ + @CordovaProperty + tempDirectory: string; + + /** + * iOS: Holds app-specific files that should be synced (e.g. to iCloud). + */ + @CordovaProperty + syncedDataDirectory: string; + + /** + * iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files) + */ + @CordovaProperty + documentsDirectory: string; + + /** + * BlackBerry10: Files globally available to all apps + */ + @CordovaProperty + sharedDirectory: string; + + cordovaFileError: {} = { 1: 'NOT_FOUND_ERR', 2: 'SECURITY_ERR', 3: 'ABORT_ERR', @@ -409,13 +480,13 @@ export class File { * * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} dir Name of directory to check - * @returns {Promise} Returns a Promise that resolves to true if the directory exists or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to true if the directory exists or rejects with an error. */ - checkDir(path: string, dir: string): Promise { + checkDir(path: string, dir: string): Promise { if ((/^\//.test(dir))) { let err = new FileError(5); err.message = 'directory cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } let fullpath = path + dir; @@ -433,13 +504,13 @@ export class File { * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} dirName Name of directory to create * @param {boolean} replace If true, replaces file with same name. If false returns error - * @returns {Promise} Returns a Promise that resolves with a DirectoryEntry or rejects with an error. + * @returns {Promise} Returns a Promise that resolves with a DirectoryEntry or rejects with an error. */ - createDir(path: string, dirName: string, replace: boolean): Promise { + createDir(path: string, dirName: string, replace: boolean): Promise { if ((/^\//.test(dirName))) { let err = new FileError(5); err.message = 'directory cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } let options: Flags = { @@ -461,13 +532,13 @@ export class File { * * @param {string} path The path to the directory * @param {string} dirName The directory name - * @returns {Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error. */ - removeDir(path: string, dirName: string): Promise { + removeDir(path: string, dirName: string): Promise { if ((/^\//.test(dirName))) { let err = new FileError(5); err.message = 'directory cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) @@ -486,15 +557,15 @@ export class File { * @param {string} dirName The source directory name * @param {string} newPath The destionation path to the directory * @param {string} newDirName The destination directory name - * @returns {Promise} Returns a Promise that resolves to the new DirectoryEntry object or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to the new DirectoryEntry object or rejects with an error. */ - moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise { + moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise { newDirName = newDirName || dirName; if ((/^\//.test(newDirName))) { let err = new FileError(5); err.message = 'directory cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) @@ -516,13 +587,13 @@ export class File { * @param {string} dirName Name of directory to copy * @param {string} newPath Base FileSystem of new location * @param {string} newDirName New name of directory to copy to (leave blank to remain the same) - * @returns {Promise} Returns a Promise that resolves to the new Entry object or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to the new Entry object or rejects with an error. */ - copyDir(path: string, dirName: string, newPath: string, newDirName: string): Promise { + copyDir(path: string, dirName: string, newPath: string, newDirName: string): Promise { if ((/^\//.test(newDirName))) { let err = new FileError(5); err.message = 'directory cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) @@ -589,13 +660,13 @@ export class File { * * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} file Name of file to check - * @returns {Promise} Returns a Promise that resolves with a boolean or rejects with an error. + * @returns {Promise} Returns a Promise that resolves with a boolean or rejects with an error. */ - checkFile(path: string, file: string): Promise { + checkFile(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); err.message = 'file cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveLocalFilesystemUrl(path + file) @@ -618,13 +689,13 @@ export class File { * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} fileName Name of file to create * @param {boolean} replace If true, replaces file with same name. If false returns error - * @returns {Promise} Returns a Promise that resolves to a FileEntry or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to a FileEntry or rejects with an error. */ - createFile(path: string, fileName: string, replace: boolean): Promise { + createFile(path: string, fileName: string, replace: boolean): Promise { if ((/^\//.test(fileName))) { let err = new FileError(5); err.message = 'file-name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } let options: Flags = { @@ -646,13 +717,13 @@ export class File { * * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} fileName Name of file to remove - * @returns {Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to a RemoveResult or rejects with an error. */ - removeFile(path: string, fileName: string): Promise { + removeFile(path: string, fileName: string): Promise { if ((/^\//.test(fileName))) { let err = new FileError(5); err.message = 'file-name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) @@ -673,7 +744,7 @@ export class File { * @returns {Promise} Returns a Promise that resolves to updated file entry or rejects with an error. */ writeFile(path: string, fileName: string, - text: string | Blob, options: WriteOptions = {}): Promise { + text: string | Blob | ArrayBuffer, options: WriteOptions = {}): Promise { if ((/^\//.test(fileName))) { const err = new FileError(5); err.message = 'file-name cannot start with \/'; @@ -686,11 +757,11 @@ export class File { }; return this.resolveDirectoryUrl(path) - .then((fse) => { - return this.getFile(fse, fileName, getFileOpts); + .then((directoryEntry: DirectoryEntry) => { + return this.getFile(directoryEntry, fileName, getFileOpts); }) - .then((fe) => { - return this.writeFileEntry(fe, text, options); + .then((fileEntry: FileEntry) => { + return this.writeFileEntry(fileEntry, text, options); }); } @@ -702,7 +773,7 @@ export class File { * @param {WriteOptions} options replace file if set to true. See WriteOptions for more information. * @returns {Promise} Returns a Promise that resolves to updated file entry or rejects with an error. */ - private writeFileEntry(fe: FileEntry, text: string | Blob, options: WriteOptions) { + private writeFileEntry(fe: FileEntry, text: string | Blob | ArrayBuffer, options: WriteOptions) { return this.createWriter(fe) .then((writer) => { if (options.append) { @@ -727,7 +798,7 @@ export class File { * @returns {Promise} Returns a Promise that resolves or rejects with an error. */ writeExistingFile(path: string, fileName: string, text: string | Blob): Promise { - return this.writeFile(path, fileName, text, { create: false }); + return this.writeFile(path, fileName, text, { replace: true }); } /** @@ -735,20 +806,20 @@ export class File { * * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} file Name of file, relative to path. - * @returns {Promise} Returns a Promise that resolves with the contents of the file as string or rejects with an error. + * @returns {Promise} Returns a Promise that resolves with the contents of the file as string or rejects with an error. */ - readAsText(path: string, file: string): Promise { + readAsText(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); err.message = 'file-name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) - .then((fse) => { - return this.getFile(fse, file, {create: false}); + .then((directoryEntry: DirectoryEntry) => { + return this.getFile(directoryEntry, file, {create: false}); }) - .then((fe) => { + .then((fileEntry: FileEntry) => { let reader = new FileReader(); return new Promise((resolve, reject) => { reader.onloadend = () => { @@ -760,7 +831,7 @@ export class File { reject({code: null, message: 'READER_ONLOADEND_ERR'}); } }; - fe.file(file => { + fileEntry.file(file => { reader.readAsText(file); }, error => { reject(error); @@ -776,20 +847,20 @@ export class File { * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} file Name of file, relative to path. - * @returns {Promise} Returns a Promise that resolves with the contents of the file as data URL or rejects with an error. + * @returns {Promise} Returns a Promise that resolves with the contents of the file as data URL or rejects with an error. */ - readAsDataURL(path: string, file: string): Promise { + readAsDataURL(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); err.message = 'file-name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) - .then((fse) => { - return this.getFile(fse, file, {create: false}); + .then((directoryEntry: DirectoryEntry) => { + return this.getFile(directoryEntry, file, {create: false}); }) - .then((fe) => { + .then((fileEntry: FileEntry) => { let reader = new FileReader(); return new Promise((resolve, reject) => { reader.onloadend = () => { @@ -804,7 +875,7 @@ export class File { - fe.file(file => { + fileEntry.file(file => { reader.readAsDataURL(file); }, error => { reject(error); @@ -818,20 +889,20 @@ export class File { * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} file Name of file, relative to path. - * @returns {Promise} Returns a Promise that resolves with the contents of the file as string rejects with an error. + * @returns {Promise} Returns a Promise that resolves with the contents of the file as string rejects with an error. */ - readAsBinaryString(path: string, file: string): Promise { + readAsBinaryString(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); err.message = 'file-name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) - .then((fse) => { - return this.getFile(fse, file, {create: false}); + .then((directoryEntry: DirectoryEntry) => { + return this.getFile(directoryEntry, file, {create: false}); }) - .then((fe) => { + .then((fileEntry: FileEntry) => { let reader = new FileReader(); return new Promise((resolve, reject) => { reader.onloadend = () => { @@ -844,7 +915,7 @@ export class File { } }; - fe.file(file => { + fileEntry.file(file => { reader.readAsBinaryString(file); }, error => { reject(error); @@ -859,20 +930,20 @@ export class File { * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above * @param {string} file Name of file, relative to path. - * @returns {Promise} Returns a Promise that resolves with the contents of the file as ArrayBuffer or rejects with an error. + * @returns {Promise} Returns a Promise that resolves with the contents of the file as ArrayBuffer or rejects with an error. */ - readAsArrayBuffer(path: string, file: string): Promise { + readAsArrayBuffer(path: string, file: string): Promise { if ((/^\//.test(file))) { let err = new FileError(5); err.message = 'file-name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) - .then((fse) => { - return this.getFile(fse, file, {create: false}); + .then((directoryEntry: DirectoryEntry) => { + return this.getFile(directoryEntry, file, {create: false}); }) - .then((fe) => { + .then((fileEntry: FileEntry) => { let reader = new FileReader(); return new Promise((resolve, reject) => { reader.onloadend = () => { @@ -885,7 +956,7 @@ export class File { } }; - fe.file(file => { + fileEntry.file(file => { reader.readAsArrayBuffer(file); }, error => { reject(error); @@ -902,15 +973,15 @@ export class File { * @param {string} fileName Name of file to move * @param {string} newPath Base FileSystem of new location * @param {string} newFileName New name of file to move to (leave blank to remain the same) - * @returns {Promise} Returns a Promise that resolves to the new Entry or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to the new Entry or rejects with an error. */ - moveFile(path: string, fileName: string, newPath: string, newFileName: string): Promise { + moveFile(path: string, fileName: string, newPath: string, newFileName: string): Promise { newFileName = newFileName || fileName; if ((/^\//.test(newFileName))) { let err = new FileError(5); err.message = 'file name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) @@ -932,15 +1003,15 @@ export class File { * @param {string} fileName Name of file to copy * @param {string} newPath Base FileSystem of new location * @param {string} newFileName New name of file to copy to (leave blank to remain the same) - * @returns {Promise} Returns a Promise that resolves to an Entry or rejects with an error. + * @returns {Promise} Returns a Promise that resolves to an Entry or rejects with an error. */ - copyFile(path: string, fileName: string, newPath: string, newFileName: string): Promise { + copyFile(path: string, fileName: string, newPath: string, newFileName: string): Promise { newFileName = newFileName || fileName; if ((/^\//.test(newFileName))) { let err = new FileError(5); err.message = 'file name cannot start with \/'; - return Promise.reject(err); + return Promise.reject(err); } return this.resolveDirectoryUrl(path) @@ -955,14 +1026,13 @@ export class File { }); } - // these private methods help avoid cascading error handling - // in the public ones, primarily simply wrapping callback - // operations to return Promises that can then be chained. /** * @private */ private fillErrorMessage(err: FileError): void { - err.message = File.cordovaFileError[err.code]; + try { + err.message = this.cordovaFileError[err.code]; + } catch (e) {} } /** @@ -1135,7 +1205,7 @@ export class File { /** * @private */ - private write(writer: FileWriter, gu: string | Blob): Promise { + private write(writer: FileWriter, gu: string | Blob | ArrayBuffer): Promise { if (gu instanceof Blob) { return this.writeFileInChunks(writer, gu); } diff --git a/src/@ionic-native/plugins/firebase/index.ts b/src/@ionic-native/plugins/firebase/index.ts index 05ddb88c7..6dbfa59ce 100644 --- a/src/@ionic-native/plugins/firebase/index.ts +++ b/src/@ionic-native/plugins/firebase/index.ts @@ -64,6 +64,15 @@ export class Firebase { }) grantPermission(): Promise { return; } + /** + * Check permission to recieve push notifications + * @return {Promise} + */ + @Cordova({ + platforms: ['iOS'] + }) + static hasPermission(): Promise { return; } + /** * Set icon badge number. Set to 0 to clear the badge. * @param badgeNumber {number} diff --git a/src/@ionic-native/plugins/google-analytics/index.ts b/src/@ionic-native/plugins/google-analytics/index.ts index d2fe79bfe..1ad55ec87 100644 --- a/src/@ionic-native/plugins/google-analytics/index.ts +++ b/src/@ionic-native/plugins/google-analytics/index.ts @@ -127,7 +127,7 @@ export class GoogleAnalytics { /** * Add a Custom Dimension * https://developers.google.com/analytics/devguides/platform/customdimsmets - * @param key {string} + * @param key {number} * @param value {string} * @returns {Promise} */ diff --git a/src/@ionic-native/plugins/google-maps/index.ts b/src/@ionic-native/plugins/google-maps/index.ts index 4d276bfc8..16864a984 100644 --- a/src/@ionic-native/plugins/google-maps/index.ts +++ b/src/@ionic-native/plugins/google-maps/index.ts @@ -38,6 +38,18 @@ export const GoogleMapsAnimation = { DROP: 'DROP' }; +/** + * @private + */ +export const GoogleMapsMapTypeId = { + HYBRID: 'MAP_TYPE_HYBRID', + NONE: 'MAP_TYPE_NONE', + NORMAL: 'MAP_TYPE_NORMAL', + ROADMAP: 'MAP_TYPE_ROADMAP', + SATELLITE: 'MAP_TYPE_SATELLITE', + TERAIN: 'MAP_TYPE_TERRAIN' +}; + /** * @private */ @@ -190,7 +202,7 @@ export class GoogleMap { setZoom(zoomLevel: number): void { } @CordovaInstance({ sync: true }) - setMapTypeId(typeId: string): void { } + setMapTypeId(mapTypeId: string): void { } @CordovaInstance({ sync: true }) setTilt(tiltLevel: number): void { } @@ -444,6 +456,7 @@ export class GoogleMap { * let map: GoogleMap = GoogleMaps.create(element); * * // listen to MAP_READY event + * // You must wait for this event to fire before adding something to the map or modifying it in anyway * map.one(GoogleMapsEvent.MAP_READY).then(() => console.log('Map is ready!')); * * // create LatLng object diff --git a/src/@ionic-native/plugins/gyroscope/index.ts b/src/@ionic-native/plugins/gyroscope/index.ts new file mode 100644 index 000000000..b8cefa780 --- /dev/null +++ b/src/@ionic-native/plugins/gyroscope/index.ts @@ -0,0 +1,109 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; +import { Injectable } from '@angular/core'; + +declare var navigator: any; + +/** + * @private + */ +export interface GyroscopeOrientation { + /** + * Represent x-axis + */ + x: number; + + /** + * Represent y-axis + */ + y: number; + + /** + * Represent z-axis + */ + z: number; + + /** + * Represent timestamp of sensor read. Default is 10000ms + */ + timestamp: number; +} + +/** + * @private + */ +export interface GyroscopeOptions { + /** + * Represent how often (in milliseconds) sensor should be read. Default is 10000 ms + */ + frequency: number; +} + +/** + * @name Gyroscope + * @description Read Gyroscope sensor data + * @usage + * ``` + * import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope'; + * + * + * constructor(private gyroscope: Gyroscope) { } + * + * ... + * + * + * let options: GyroscopeOptions = { + * frequency: 1000 + * }; + * + * this.gyroscope.getCurrent(options) + * .then((orientation: GyroscopeOrientation) => { + * console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp); + * }) + * .catch() + * + * + * this.gyroscope.watch() + * .subscribe((orientation: GyroscopeOrientation) => { + * console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp); + * }); + * + * ``` + * @interfaces + * GyroscopeOrientation + * GyroscopeOptions + */ +@Plugin({ + pluginName: 'Gyroscope', + plugin: 'cordova-plugin-gyroscope', + pluginRef: 'navigator.gyroscope', + repo: 'https://github.com/NeoLSN/cordova-plugin-gyroscope', + platforms: ['Android', 'iOS'] +}) +@Injectable() +export class Gyroscope { + + /** + * Watching for gyroscope sensor changes + * @param options {GyroscopeOptions} (optional) + * @return {Observable} Returns an Observable that resolves GyroscopeOrientation + */ + watch(options?: GyroscopeOptions): Observable { + return new Observable ( + (observer: any) => { + let watchId = navigator.gyroscope.watch(observer.next.bind(observer), observer.next.bind(observer), options); + return () => navigator.gyroscope.clearWatch(watchId); + } + ); + } + + /** + * Get current data from gyroscope sensor + * @param options {GyroscopeOptions} (optional) + * @return {Promise} Returns a promise that resolves GyroscopeOrientation + */ + @Cordova({ + callbackOrder: 'reverse' + }) + getCurrent(options?: GyroscopeOptions): Promise { return; } +} diff --git a/src/@ionic-native/plugins/health/index.ts b/src/@ionic-native/plugins/health/index.ts new file mode 100644 index 000000000..2c3fb8d09 --- /dev/null +++ b/src/@ionic-native/plugins/health/index.ts @@ -0,0 +1,307 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @private + */ +export interface HealthQueryOptions { + /** + * Start date from which to get data + */ + startDate: Date; + + /** + * End date from which to get data + */ + endDate: Date; + + /** + * Datatype to be queried (see https://github.com/dariosalvi78/cordova-plugin-health#supported-data-types) + */ + dataType: string; + + /** + * Optional limit the number of values returned. Defaults to 1000 + */ + limit?: number; + + /** + * Optional indicator to sort values ascending or descending + */ + ascending?: boolean; + + /** + * In Android, it is possible to query for "raw" steps or to select those as filtered by the Google Fit app. + * In the latter case the query object must contain the field filtered: true. + */ + filtered?: boolean; +} + +/** + * @private + */ +export interface HealthQueryOptionsAggregated { + /** + * Start date from which to get data + */ + startDate: Date; + + /** + * End date from which to get data + */ + endDate: Date; + + /** + * Datatype to be queried (see https://github.com/dariosalvi78/cordova-plugin-health#supported-data-types) + */ + dataType: string; + + /** + * if specified, aggregation is grouped an array of "buckets" (windows of time), + * supported values are: 'hour', 'day', 'week', 'month', 'year'. + */ + bucket: string; +} + +/** + * @private + */ +export interface HealthStoreOptions { + /** + * Start date from which to get data + */ + startDate: Date; + + /** + * End date from which to get data + */ + endDate: Date; + + /** + * Datatype to be queried (see https://github.com/dariosalvi78/cordova-plugin-health#supported-data-types) + */ + dataType: string; + + /** + * Value of corresponding Datatype (see "Overview of valid datatypes") + */ + value: string; + + /* + * The source that produced this data. In iOS this is ignored and + * set automatically to the name of your app. + */ + sourceName: string; + + /* + * The complete package of the source that produced this data. + * In Android, if not specified, it's assigned to the package of the App. In iOS this is ignored and + * set automatically to the bunde id of the app. + */ + sourceBundleId: string; +} + +/** + * @private + */ +export interface HealthData { + /** + * Start date from which to get data + */ + startDate: Date; + + /** + * End date from which to get data + */ + endDate: Date; + + /** + * Value of corresponding Datatype (see https://github.com/dariosalvi78/cordova-plugin-health#supported-data-types) + */ + value: string; + + /** + * Unit of corresponding value of Datatype (see https://github.com/dariosalvi78/cordova-plugin-health#supported-data-types) + */ + unit: string; + + /** + * The source that produced this data. In iOS this is ignored and + * set automatically to the name of your app. + */ + sourceName: string; + + /** + * The complete package of the source that produced this data. + * In Android, if not specified, it's assigned to the package of the App. In iOS this is ignored and + * set automatically to the bunde id of the app. + */ + sourceBundleId: string; +} + +/** + * @name Health + * @description + * A plugin that abstracts fitness and health repositories like Apple HealthKit or Google Fit. + * + * @usage + * ``` + * import { Health } from '@ionic-native/health'; + * + * + * constructor(private health: Health) { } + * + * + * ``` + * See description at https://github.com/dariosalvi78/cordova-plugin-health for a full list of Datatypes and see examples. + * + * @interfaces + * HealthQueryOptions + * HealthQueryOptionsAggregated + * HealthStoreOptions + * HealthData + */ +@Injectable() +@Plugin({ + pluginName: 'Health', + plugin: 'cordova-plugin-health', + pluginRef: 'navigator.health', + repo: 'https://github.com/dariosalvi78/cordova-plugin-health' +}) +export class Health { + + /** + * Tells if either Google Fit or HealthKit are available. + * + * @return {Promise} + */ + @Cordova({ + callbackOrder: 'reverse' + }) + isAvailable(): Promise { return; } + + /** + * Checks if recent Google Play Services and Google Fit are installed. If the play services are not installed, + * or are obsolete, it will show a pop-up suggesting to download them. If Google Fit is not installed, + * it will open the Play Store at the location of the Google Fit app. + * The plugin does not wait until the missing packages are installed, it will return immediately. + * If both Play Services and Google Fit are available, this function just returns without any visible effect. + * + * This function is only available on Android. + * + * @return {Promise} + */ + @Cordova({ + callbackOrder: 'reverse' + }) + promptInstallFit(): Promise { return; } + + /** + * Requests read and write access to a set of data types. It is recommendable to always explain why the app + * needs access to the data before asking the user to authorize it. + * This function must be called before using the query and store functions, even if the authorization has already + * been given at some point in the past. + * + * Quirks of requestAuthorization() + + * In Android, it will try to get authorization from the Google Fit APIs. + * It is necessary that the app's package name and the signing key are registered in the Google API console. + * In Android, be aware that if the activity is destroyed (e.g. after a rotation) or is put in background, + * the connection to Google Fit may be lost without any callback. Going through the authorization will ensure that + * the app is connected again. + * In Android 6 and over, this function will also ask for some dynamic permissions if needed + * (e.g. in the case of "distance", it will need access to ACCESS_FINE_LOCATION). + * + * @param {Array} datatypes a list of data types you want to be granted access to + * + * @return {Promise} + */ + @Cordova() + requestAuthorization(datatypes: Array): Promise { return; } + + /** + * Check if the app has authorization to read/write a set of datatypes. + * This function is similar to requestAuthorization() and has similar quirks. + * + * @param {Array} datatypes a list of data types you want to be granted access to + * @return {type: function(authorized)}, if the argument is true, the app is authorized + */ + @Cordova() + isAuthorized(datatypes: Array): Promise { return; } + + /** + * Gets all the data points of a certain data type within a certain time window. + * Warning: if the time span is big, it can generate long arrays! + * + * Quirks of query() + * + * In iOS, the amount of datapoints is limited to 1000 by default. + * You can override this by adding a limit: xxx to your query object. + * In iOS, datapoints are ordered in an descending fashion (from newer to older). + * You can revert this behaviour by adding ascending: true to your query object. + * In Android, it is possible to query for "raw" steps or to select those as filtered by the Google Fit app. + * In the latter case the query object must contain the field filtered: true. + * In Google Fit, calories.basal is returned as an average per day, and usually is not available in all days. + * In Google Fit, calories.active is computed by subtracting the basal calories from the total. + * As basal energy expenditure, an average is computed from the week before endDate. + * While Google Fit calculates basal and active calories automatically, + * HealthKit needs an explicit input from some app. + * When querying for activities, Google Fit is able to determine some activities automatically + * (still, walking, running, biking, in vehicle), while HealthKit only relies on the input of + * the user or of some external app. + * When querying for activities, calories and distance are also provided in HealthKit (units are kcal and meters) and + * never in Google Fit. + * When querying for nutrition, Google Fit always returns all the nutrition elements it has, + * while HealthKit returns only those that are stored as correlation. To be sure to get all stored the quantities + * (regardless of they are stored as correlation or not), it's better to query single nutrients. + * nutrition.vitamin_a is given in micrograms in HealthKit and International Unit in Google Fit. + * Automatic conversion is not trivial and depends on the actual substance. + * + * @param queryOptions {HealthQueryOptions} + * @return {Promise} + */ + @Cordova() + query(queryOptions: HealthQueryOptions): Promise { return; } + + /** + * Gets aggregated data in a certain time window. Usually the sum is returned for the given quantity. + * + * Quirks of queryAggregated() + * In Android, to query for steps as filtered by the Google Fit app, the flag filtered: + * true must be added into the query object. + * When querying for activities, calories and distance are provided + * when available in HealthKit and never in Google Fit. + * In Android, the start and end dates returned are the date of the first and the last available samples. + * If no samples are found, start and end may not be set. + * When bucketing, buckets will include the whole hour / day / month / week / year where start and end times + * fall into. For example, if your start time is 2016-10-21 10:53:34, + * the first daily bucket will start at 2016-10-21 00:00:00. + * Weeks start on Monday. + * When querying for nutrition, HealthKit returns only those that are stored as correlation. + * To be sure to get all the stored quantities, it's better to query single nutrients. + * nutrition.vitamin_a is given in micrograms in HealthKit and International Unit in Google Fit. + * + * @param queryOptionsAggregated + * @return {Promise} + */ + @Cordova() + queryAggregated(queryOptionsAggregated: HealthQueryOptionsAggregated): Promise { return; } + + /** + * Stores a data point. + * + * Quirks of store() + * + * Google Fit doesn't allow you to overwrite data points that overlap with others already stored of the same type (see here). At the moment there is no support for update nor delete. + * In iOS you cannot store the total calories, you need to specify either basal or active. If you use total calories, the active ones will be stored. + * In Android you can only store active calories, as the basal are estimated automatically. If you store total calories, these will be treated as active. + * In iOS distance is assumed to be of type WalkingRunning, if you want to explicitly set it to Cycling you need to add the field cycling: true. + * In iOS storing the sleep activities is not supported at the moment. + * Storing of nutrients is not supported at the moment. + * @param storeOptions + * @return {Promise} + */ + @Cordova() + store(storeOptions: HealthStoreOptions): Promise { return; } + +} diff --git a/src/@ionic-native/plugins/ibeacon/index.ts b/src/@ionic-native/plugins/ibeacon/index.ts index 98afd9b32..2e6cc9147 100644 --- a/src/@ionic-native/plugins/ibeacon/index.ts +++ b/src/@ionic-native/plugins/ibeacon/index.ts @@ -548,11 +548,11 @@ export class IBeacon { /** * Queries the native layer to determine the current authorization in effect. * - * @returns {Promise} Returns a promise which is resolved with the + * @returns {Promise} Returns a promise which is resolved with the * requested authorization status. */ @Cordova({otherPromise: true}) - getAuthorizationStatus(): Promise { return; } + getAuthorizationStatus(): Promise { return; } /** * For iOS 8 and above only. The permission model has changed by Apple in iOS 8, making it necessary for apps to @@ -568,7 +568,7 @@ export class IBeacon { /** - * See the docuemntation of {@code requestWhenInUseAuthorization} for further details. + * See the documentation of {@code requestWhenInUseAuthorization} for further details. * * @returns {Promise} Returns a promise which is resolved when the native layer * shows the request dialog. diff --git a/src/@ionic-native/plugins/image-picker/index.ts b/src/@ionic-native/plugins/image-picker/index.ts index 7b84e9348..f8bdd8f98 100644 --- a/src/@ionic-native/plugins/image-picker/index.ts +++ b/src/@ionic-native/plugins/image-picker/index.ts @@ -21,6 +21,11 @@ export interface ImagePickerOptions { * Quality of images, defaults to 100 */ quality?: number; + + /** + * Output type, defaults to 0 (FILE_URI). + */ + outputType?: number; } /** diff --git a/src/@ionic-native/plugins/in-app-browser/index.ts b/src/@ionic-native/plugins/in-app-browser/index.ts index b2e5b8bfb..a05cac280 100644 --- a/src/@ionic-native/plugins/in-app-browser/index.ts +++ b/src/@ionic-native/plugins/in-app-browser/index.ts @@ -5,6 +5,50 @@ import 'rxjs/add/observable/fromEvent'; declare var cordova: any; +export interface InAppBrowserOptions { + /** Set to yes or no to ruen the InAppBrowser's location bar on or off. */ + location?: 'yes' | 'no'; + /** Set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. + * Omit or set to no (default) to have the browser open and load normally. */ + hidden?: 'yes' | 'no'; + /** Set to yes to have the browser's cookie cache cleared before the new window is opened. */ + clearcache?: 'yes'; + /** Set to yes to have the session cookie cache cleared before the new window is opened. */ + clearsessioncache?: 'yes'; + /** (Android Only) set to yes to show Android browser's zoom controls, set to no to hide them. Default value is yes. */ + zoom?: 'yes' | 'no'; + /** Set to yes to use the hardware back button to navigate backwards through the InAppBrowser's history. + * If there is no previous page, the InAppBrowser will close. The default value is yes, so you must set it to no if you want the back button to simply close the InAppBrowser. */ + hardwareback?: 'yes' | 'no'; + /** Set to yes to prevent HTML5 audio or video from autoplaying (defaults to no). */ + mediaPlaybackRequiresUserAction?: 'yes' | 'no'; + /** (Android Only) Set to yes to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues) */ + shouldPauseOnSuspend?: 'yes' | 'no'; + /** (iOS Only) Set to a string to use as the Done button's caption. Note that you need to localize this value yourself. */ + closebuttoncaption?: string; + /** (iOS Only) Set to yes or no (default is no). Turns on/off the UIWebViewBounce property. */ + disallowoverscroll?: 'yes' | 'no'; + /** (iOS Only) Set to yes or no to turn the toolbar on or off for the InAppBrowser (defaults to yes) */ + toolbar?: 'yes' | 'no'; + /** (iOS Only) Set to yes or no to prevent viewport scaling through a meta tag (defaults to no). */ + enableViewportScale?: 'yes' | 'no'; + /** (iOS Only) Set to yes or no to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. + * The HTML's video element must also include the webkit-playsinline attribute (defaults to no) */ + allowInlineMediaPlayback?: 'yes' | 'no'; + /** (iOS Only) Set to yes or no to open the keyboard when form elements receive focus via JavaScript's focus() call (defaults to yes). */ + keyboardDisplayRequiresUserAction?: 'yes' | 'no'; + /** (iOS Only) Set to yes or no to wait until all new view content is received before being rendered (defaults to no). */ + suppressesIncrementalRendering?: 'yes' | 'no'; + /** (iOS Only) Set to pagesheet, formsheet or fullscreen to set the presentation style (defaults to fullscreen). */ + presentationstyle?: 'pagesheet' | 'formsheet' | 'fullscreen'; + /** (iOS Only) Set to fliphorizontal, crossdissolve or coververtical to set the transition style (defaults to coververtical). */ + transitionstyle?: 'fliphorizontal' | 'crossdissolve' | 'coververtical'; + /** (iOS Only) Set to top or bottom (default is bottom). Causes the toolbar to be at the top or bottom of the window. */ + toolbarposition?: 'top' | 'bottom'; + /** (Windows only) Set to yes to create the browser control without a border around it. + * Please note that if location=no is also specified, there will be no control presented to user to close IAB window. */ + fullscreen?: 'yes'; +} export interface InAppBrowserEvent extends Event { /** the eventname, either loadstart, loadstop, loaderror, or exit. */ type: string; @@ -23,8 +67,18 @@ export class InAppBrowserObject { private _objectInstance: any; - constructor(url: string, target?: string, options?: string) { + /** + * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. + * @param url The URL to load. + * @param target The target in which to load the URL, an optional parameter that defaults to _self. + * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. + * The options string must not contain any blank space, and each feature's + * name/value pairs must be separated by a comma. Feature names are case insensitive. + */ + constructor(url: string, target?: string, options?: string | InAppBrowserOptions) { try { + if (options && typeof options !== 'string') + options = Object.keys(options).map(key => `${key}=${options[key]}`).join(','); this._objectInstance = cordova.InAppBrowser.open(url, target, options); } catch (e) { window.open(url); @@ -36,20 +90,20 @@ export class InAppBrowserObject { * Displays an InAppBrowser window that was opened hidden. Calling this has no effect * if the InAppBrowser was already visible. */ - @CordovaInstance({sync: true}) + @CordovaInstance({ sync: true }) show(): void { } /** * Closes the InAppBrowser window. */ - @CordovaInstance({sync: true}) + @CordovaInstance({ sync: true }) close(): void { } /** * Hides an InAppBrowser window that is currently shown. Calling this has no effect * if the InAppBrowser was already hidden. */ - @CordovaInstance({sync: true}) + @CordovaInstance({ sync: true }) hide(): void { } /** @@ -58,7 +112,7 @@ export class InAppBrowserObject { * @returns {Promise} */ @CordovaInstance() - executeScript(script: {file?: string, code?: string}): Promise {return; } + executeScript(script: { file?: string, code?: string }): Promise { return; } /** * Injects CSS into the InAppBrowser window. @@ -66,7 +120,7 @@ export class InAppBrowserObject { * @returns {Promise} */ @CordovaInstance() - insertCSS(css: {file?: string, code?: string}): Promise {return; } + insertCSS(css: { file?: string, code?: string }): Promise { return; } /** * A method that allows you to listen to events happening in the browser. @@ -98,6 +152,7 @@ export class InAppBrowserObject { * InAppBrowserObject * @interfaces * InAppBrowserEvent + * InAppBrowserOptions */ @Plugin({ pluginName: 'InAppBrowser', @@ -117,7 +172,7 @@ export class InAppBrowser { * name/value pairs must be separated by a comma. Feature names are case insensitive. * @returns {InAppBrowserObject} */ - create(url: string, target?: string, options?: string): InAppBrowserObject { + create(url: string, target?: string, options?: string | InAppBrowserOptions): InAppBrowserObject { return new InAppBrowserObject(url, target, options); } diff --git a/src/@ionic-native/plugins/local-notifications/index.ts b/src/@ionic-native/plugins/local-notifications/index.ts index fd915c680..674203ba3 100644 --- a/src/@ionic-native/plugins/local-notifications/index.ts +++ b/src/@ionic-native/plugins/local-notifications/index.ts @@ -66,6 +66,13 @@ export interface ILocalNotification { */ smallIcon?: string; + /** + * ANDROID ONLY + * RGB value for the background color of the smallIcon. + * Default: Androids COLOR_DEFAULT, which will vary based on Android version. + */ + color?: string; + /** * ANDROID ONLY diff --git a/src/@ionic-native/plugins/media/index.ts b/src/@ionic-native/plugins/media/index.ts index 71ab94688..85bec9464 100644 --- a/src/@ionic-native/plugins/media/index.ts +++ b/src/@ionic-native/plugins/media/index.ts @@ -161,6 +161,21 @@ export class MediaObject { }) stopRecord(): void { } + /** + * Pauses recording + */ + @CordovaInstance({ + sync: true + }) + pauseRecord(): void { } + + /** + * Resumes recording + */ + @CordovaInstance({ + sync: true + }) + resumeRecord(): void { } /** * Stops playing an audio file. diff --git a/src/@ionic-native/plugins/pay-pal/index.ts b/src/@ionic-native/plugins/pay-pal/index.ts index 107f24801..3e7cfd488 100644 --- a/src/@ionic-native/plugins/pay-pal/index.ts +++ b/src/@ionic-native/plugins/pay-pal/index.ts @@ -195,7 +195,7 @@ export class PayPalPayment { /** * Optional array of PayPalItem objects. */ - items: string; + items: Array; /** * Optional customer shipping address, if your app wishes to provide this to the SDK. diff --git a/src/@ionic-native/plugins/photo-library/index.ts b/src/@ionic-native/plugins/photo-library/index.ts new file mode 100644 index 000000000..793206a7b --- /dev/null +++ b/src/@ionic-native/plugins/photo-library/index.ts @@ -0,0 +1,223 @@ +import { Plugin, Cordova, CordovaFiniteObservable } from '@ionic-native/core'; +import { Observable } from 'rxjs/Observable'; +import { Injectable } from '@angular/core'; + +/** + * @name Photo Library + * @description + * The PhotoLibrary plugin allows access to photos from device by url. So you can use plain img tag to display photos and their thumbnails, and different 3rd party libraries as well. + * Saving photos and videos to the library is also supported. + * cdvphotolibrary urls should be trusted by Angular. See plugin homepage to learn how. + * + * @usage + * ``` + * import { PhotoLibrary } from '@ionic-native/photo-library'; + * + * constructor(private photoLibrary: PhotoLibrary) { } + * + * this.photoLibrary.requestAuthorization().then(() => { + * this.photoLibrary.getLibrary().subscribe({ + * next: library => { + * library.forEach(function(libraryItem) { + * console.log(libraryItem.id); // ID of the photo + * console.log(libraryItem.photoURL); // Cross-platform access to photo + * console.log(libraryItem.thumbnailURL);// Cross-platform access to thumbnail + * console.log(libraryItem.fileName); + * console.log(libraryItem.width); + * console.log(libraryItem.height); + * console.log(libraryItem.creationDate); + * console.log(libraryItem.latitude); + * console.log(libraryItem.longitude); + * console.log(libraryItem.albumIds); // array of ids of appropriate AlbumItem, only of includeAlbumsData was used + * }); + * }, + * error: err => {}, + * complete: () => { console.log("could not get photos"); } + * }); + * }) + * .catch(err => console.log("permissions weren't granted")); + * + * ``` + */ +@Plugin({ + pluginName: 'PhotoLibrary', + plugin: 'cordova-plugin-photo-library', + pluginRef: 'cordova.plugins.photoLibrary', + repo: 'https://github.com/terikon/cordova-plugin-photo-library', + install: 'ionic plugin add cordova-plugin-photo-library --variable PHOTO_LIBRARY_USAGE_DESCRIPTION="To choose photos"' +}) +@Injectable() +export class PhotoLibrary { + + /** + * Retrieves library items. Library item contains photo metadata like width and height, as well as photoURL and thumbnailURL. + * @param options {GetLibraryOptions} Optional, like thumbnail size and chunks settings. + * @return {Observable} Returns library items. If appropriate option was set, will be returned by chunks. + */ + @CordovaFiniteObservable({ + callbackOrder: 'reverse', + resultFinalPredicate: (result: {isLastChunk: boolean}) => { return result.isLastChunk; }, + resultTransform: (result: {library: LibraryItem[]}) => { return result.library; }, + }) + getLibrary(options?: GetLibraryOptions): Observable { return; } + + /** + * Asks user permission to access photo library. + * @param options {RequestAuthorizationOptions} Optional, like whether only read access needed or read/write. + * @return { Promise} Returns a promise that resolves when permissions are granted, and fails when not. + */ + @Cordova({ + callbackOrder: 'reverse', + }) + requestAuthorization(options?: RequestAuthorizationOptions): Promise { return; } + + /** + * Returns list of photo albums on device. + * @return {Promise} Resolves to list of albums. + */ + @Cordova({ + callbackOrder: 'reverse', + }) + getAlbums(): Promise { return; } + + /** + * Provides means to request URL of thumbnail, with specified size or quality. + * @param photo {string | LibraryItem} Id of photo, or LibraryItem. + * @param options {GetThumbnailOptions} Options, like thumbnail size or quality. + * @return {Promise} Resolves to URL of cdvphotolibrary schema. + */ + @Cordova({ + successIndex: 1, + errorIndex: 2 + }) + getThumbnailURL(photo: string | LibraryItem, options?: GetThumbnailOptions): Promise { return; } + + /** + * Provides means to request photo URL by id. + * @param photo {string | LibraryItem} Id or LibraryItem. + * @param options {GetPhotoOptions} Optional options. + * @return {Promise} Resolves to URL of cdvphotolibrary schema. + */ + @Cordova({ + successIndex: 1, + errorIndex: 2 + }) + getPhotoURL(photo: string | LibraryItem, options?: any): Promise { return; } + + /** + * Returns thumbnail as Blob. + * @param photo {string | LibraryItem} Id or LibraryItem. + * @param options {GetThumbnailOptions} Options, like thumbnail size or quality. + * @return {Promise} Resolves requested thumbnail as blob. + */ + @Cordova({ + successIndex: 1, + errorIndex: 2 + }) + getThumbnail(photo: string | LibraryItem, options?: GetThumbnailOptions): Promise { return; } + + /** + * Returns photo as Blob. + * @param photo {string | LibraryItem} Id or LibraryItem. + * @param options {GetPhotoOptions} Optional options. + * @return {Promise} Resolves requested photo as blob. + */ + @Cordova({ + successIndex: 1, + errorIndex: 2 + }) + getPhoto(photo: string | LibraryItem, options?: any): Promise { return; } + + /** + * Saves image to specified album. Album will be created if not exists. + * LibraryItem that represents saved image is returned. + * @param url {string} URL of a file, or DataURL. + * @param album {AlbumItem | string} Name of an album or AlbumItem object. + * @param options {GetThumbnailOptions} Options, like thumbnail size for resulting LibraryItem. + * @return {Promise} Resolves to LibraryItem that represents saved image. + */ + @Cordova({ + successIndex: 2, + errorIndex: 3 + }) + saveImage(url: string, album: AlbumItem | string, options?: GetThumbnailOptions): Promise { return; } + + /** + * Saves video to specified album. Album will be created if not exists. + * @param url {string} URL of a file, or DataURL. + * @param album {AlbumItem | string} Name of an album or AlbumItem object. + * @return {Promise} Resolves when save operation completes. + */ + @Cordova({ + successIndex: 2, + errorIndex: 3 + }) + saveVideo(url: string, album: AlbumItem | string): Promise { return; } + +} + +/** + * @private + */ +export interface LibraryItem { + /** + * Local id of the photo + */ + id: string; + /** + * URL of cdvphotolibrary schema. + */ + photoURL: string; + /** + * URL of cdvphotolibrary schema. + */ + thumbnailURL: string; + fileName: string; + width: number; + height: number; + creationDate: Date; + latitude?: number; + longitude?: number; + albumIds?: string[]; +} + +/** + * @private + */ +export interface AlbumItem { + /** + * Local id of the album + */ + id: string; + title: string; +} + +/** + * @private + */ +export interface GetLibraryOptions { + thumbnailWidth?: number; + thumbnailHeight?: number; + quality?: number; + itemsInChunk?: number; + chunkTimeSec?: number; + useOriginalFileNames?: boolean; + includeAlbumData?: boolean; +} + +/** + * @private + */ +export interface RequestAuthorizationOptions { + read?: boolean; + write?: boolean; +} + +/** + * @private + */ +export interface GetThumbnailOptions { + thumbnailWidth?: number; + thumbnailHeight?: number; + quality?: number; +} diff --git a/src/@ionic-native/plugins/pin-dialog/index.ts b/src/@ionic-native/plugins/pin-dialog/index.ts index ae4d37223..157fae9aa 100644 --- a/src/@ionic-native/plugins/pin-dialog/index.ts +++ b/src/@ionic-native/plugins/pin-dialog/index.ts @@ -36,7 +36,8 @@ export class PinDialog { * @returns {Promise<{ buttonIndex: number, input1: string }>} */ @Cordova({ - successIndex: 1 + successIndex: 1, + errorIndex: 4 // no error callback }) prompt(message: string, title: string, buttons: string[]): Promise<{ buttonIndex: number, input1: string }> { return; } diff --git a/src/@ionic-native/plugins/push/index.ts b/src/@ionic-native/plugins/push/index.ts index 9b0bfabc2..0dde0a3da 100644 --- a/src/@ionic-native/plugins/push/index.ts +++ b/src/@ionic-native/plugins/push/index.ts @@ -276,6 +276,11 @@ export interface AndroidPushOptions { */ vibrate?: boolean | string; + /** + * If true the icon badge will be cleared on init and before push messages are processed. + */ + clearBadge?: boolean | string; + /** * If true the app clears all pending notifications when it is closed. */ diff --git a/src/@ionic-native/plugins/safari-view-controller/index.ts b/src/@ionic-native/plugins/safari-view-controller/index.ts index 9a6747337..6af178b9a 100644 --- a/src/@ionic-native/plugins/safari-view-controller/index.ts +++ b/src/@ionic-native/plugins/safari-view-controller/index.ts @@ -83,7 +83,7 @@ export class SafariViewController { * Hides Safari View Controller */ @Cordova() - hide(): void { } + hide(): Promise { 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. diff --git a/src/@ionic-native/plugins/screen-orientation/index.ts b/src/@ionic-native/plugins/screen-orientation/index.ts index bd755f713..9f60bfed0 100644 --- a/src/@ionic-native/plugins/screen-orientation/index.ts +++ b/src/@ionic-native/plugins/screen-orientation/index.ts @@ -50,11 +50,10 @@ export class ScreenOrientation { /** * Lock the orientation to the passed value. * See below for accepted values - * @param orientation {string} The orientation which should be locked. Accepted values see table below. - * @returns {Promise} returns a promise that resolves when the screen orientation is locked, and rejects when an error occurs. + * @param orientation {string} The orientation which should be locked. Accepted values see table above. */ - @Cordova({ otherPromise: true }) - lockOrientation(orientation: string): Promise { return; } + @Cordova({ sync: true }) + lockOrientation(orientation: string): void { } /** * Unlock and allow all orientations. @@ -66,5 +65,5 @@ export class ScreenOrientation { * Get the current orientation of the device. */ @CordovaProperty - static orientation: string; + orientation: string; } diff --git a/src/@ionic-native/plugins/serial/index.ts b/src/@ionic-native/plugins/serial/index.ts index 7820f89f6..a679e48c5 100644 --- a/src/@ionic-native/plugins/serial/index.ts +++ b/src/@ionic-native/plugins/serial/index.ts @@ -24,13 +24,9 @@ export interface SerialOpenOptions { * ``` * import { Serial } from '@ionic-native/serial'; * - * Serial.requestPermission({ - * vid: '0403', - * pid: '6001', - * driver: 'FtdiSerialDriver' - * }).then(() => { + * Serial.requestPermission().then(() => { * Serial.open({ - * baudRate: 38400 + * baudRate: 9800 * }).then(() => { * console.log('Serial connection opened'); * }); @@ -51,11 +47,14 @@ export class Serial { /** * Request permission to connect to a serial device * - * @param options {SerialPermissionOptions} Options used to request serial permissions + * @param options {SerialPermissionOptions} Options used to request serial permissions for an unknown device * @return {Promise} Returns a promise that resolves when permissions are granted */ - @Cordova() - requestPermission(options: SerialPermissionOptions): Promise { return; } + @Cordova({ + successIndex: 1, + errorIndex: 2 + }) + requestPermission(options?: SerialPermissionOptions): Promise { return; } /** * Open connection to a serial device diff --git a/src/@ionic-native/plugins/stripe/index.ts b/src/@ionic-native/plugins/stripe/index.ts index 9c0aed46b..d94f61fca 100644 --- a/src/@ionic-native/plugins/stripe/index.ts +++ b/src/@ionic-native/plugins/stripe/index.ts @@ -53,7 +53,6 @@ export interface StripeCardTokenParams { } /** - * @beta * @name Stripe * @description * A plugin that allows you to use Stripe's Native SDKs for Android and iOS. @@ -68,10 +67,10 @@ export interface StripeCardTokenParams { * number: '4242424242424242', * expMonth: 12, * expYear: 2020, - * cvc: 220 + * cvc: '220' * }; * - * Stripe.createToken(card) + * Stripe.createCardToken(card) * .then(token => console.log(token)) * .catch(error => console.error(error)); * diff --git a/src/@ionic-native/plugins/text-to-speech/index.ts b/src/@ionic-native/plugins/text-to-speech/index.ts index 888da78ce..7eca15470 100644 --- a/src/@ionic-native/plugins/text-to-speech/index.ts +++ b/src/@ionic-native/plugins/text-to-speech/index.ts @@ -49,4 +49,8 @@ export class TextToSpeech { return; } + static stop(): Promise { + return; + } + } diff --git a/src/@ionic-native/plugins/unique-device-id/index.ts b/src/@ionic-native/plugins/unique-device-id/index.ts new file mode 100644 index 000000000..1674c9689 --- /dev/null +++ b/src/@ionic-native/plugins/unique-device-id/index.ts @@ -0,0 +1,39 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +/** + * @name Unique Device ID + * @description + * This plugin produces a unique, cross-install, app-specific device id. + * + * @usage + * ``` + * import { UniqueDeviceID } from '@ionic-native/unique-device-id'; + * + * constructor(private uniqueDeviceID: UniqueDeviceID) { } + * + * ... + * + * this.uniqueDeviceID.get() + * .then((uuid: any) => console.log(uuid)) + * .catch((error: any) => console.log(error)); + * + * ``` + */ +@Plugin({ + pluginName: 'UniqueDeviceID', + plugin: 'cordova-plugin-uniquedeviceid', + pluginRef: 'window.plugins.uniqueDeviceID', + repo: 'https://github.com/Paldom/UniqueDeviceID' +}) +@Injectable() +export class UniqueDeviceID { + + /** + * Gets a unique, cross-install, app-specific device id. + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + get(): Promise { return; } + +} diff --git a/src/@ionic-native/plugins/zip/index.ts b/src/@ionic-native/plugins/zip/index.ts index 36e2973fe..b70d307aa 100644 --- a/src/@ionic-native/plugins/zip/index.ts +++ b/src/@ionic-native/plugins/zip/index.ts @@ -26,6 +26,7 @@ import { Plugin, Cordova } from '@ionic-native/core'; }) @Injectable() export class Zip { + /** * Extracts files from a ZIP archive * @param sourceZip {string} Source ZIP file @@ -37,6 +38,6 @@ export class Zip { successIndex: 2, errorIndex: 4 }) - unzip(sourceZip: string, destUrl: string, onProgress: Function): Promise {return; } + unzip(sourceZip: string, destUrl: string, onProgress?: Function): Promise {return; } } diff --git a/test/plugins/inappbrowser.spec.ts b/test/plugins/inappbrowser.spec.ts new file mode 100644 index 000000000..9c7c3eee6 --- /dev/null +++ b/test/plugins/inappbrowser.spec.ts @@ -0,0 +1,30 @@ +import { InAppBrowser, InAppBrowserEvent, InAppBrowserOptions } from '../../src/plugins/inappbrowser'; + +declare var window: any; + +window.cordova = { + InAppBrowser: { + open: window.open + } +}; + +describe('InAppBrowser', () => { + + const options: InAppBrowserOptions = { hidden: 'yes', hardwareback: 'no' }; + let object; + + it('should create an object using strings and InAppBrowserOptions signature', () => { + object = new InAppBrowser('http://google.com', '_self', options); + expect(object).toBeDefined(); + }); + + it('should create an object using string only signature', () => { + object = new InAppBrowser('http://google.com', '_self', 'location=no'); + expect(object).toBeDefined(); + }); + + it('should create an object with the least amount of parameters', () => { + object = new InAppBrowser('http://google.com'); + expect(object).toBeDefined(); + }); +});