From f0d5b88ec47a1ddcb22218f7661259adae5ec4db Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Fri, 13 May 2016 01:26:05 +0200 Subject: [PATCH 1/5] * Add background geolocation plugin from https://github.com/mauron85/cordova-plugin-background-geolocation --- src/plugins/background-geolocation.ts | 259 ++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 src/plugins/background-geolocation.ts diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts new file mode 100644 index 000000000..dd9ebf9f8 --- /dev/null +++ b/src/plugins/background-geolocation.ts @@ -0,0 +1,259 @@ +import {Plugin, Cordova} from './plugin'; +import {Observable} from 'rxjs/Observable'; + +declare var window; + + +export interface Location { + + /** + * ID of location as stored in DB (or null) + */ + locationId: number; + + /** + * Service provider + */ + serviceProvider: string; + + /** + * true if location recorded as part of debug + */ + debug: boolean + + /** + * UTC time of this fix, in milliseconds since January 1, 1970. + */ + time: number; + + /** + * latitude, in degrees. + */ + latitude: number; + + /** + * longitude, in degrees. + */ + longitude: number; + + /** + * estimated accuracy of this location, in meters. + */ + accuracy: number; + + /** + * speed if it is available, in meters/second over ground. + */ + speed: number; + + /** + * altitude if available, in meters above the WGS 84 reference ellipsoid. + */ + altitude: number; + + /** + * bearing, in degrees. + */ + bearing: number; + + /** + * A Coordinates object defining the current location + */ + coords: Coordinates; + + /** + * A timestamp representing the time at which the location was retrieved. + */ + timestamp: number; +} + +export interface BGeoOptions { + + /** + * Desired accuracy in meters. Possible values [0, 10, 100, 1000]. The lower + * the number, the more power devoted to GeoLocation resulting in higher + * accuracy readings. 1000 results in lowest power drain and least accurate + * readings. @see Apple docs (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instp/CLLocationManager/desiredAccuracy) + */ + desiredAccuracy: number; + + /** + * Stationary radius in meters. When stopped, the minimum distance the device + * must move beyond the stationary location for aggressive background-tracking + * to engage. + */ + stationaryRadius: number; + + /** + * When enabled, the plugin will emit sounds for life-cycle events of + * background-geolocation! See debugging sounds table. + */ + debug: boolean; + + /** + * The minimum distance (measured in meters) a device must move horizontally + * before an update event is generated. @see Apple docs. (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/distanceFilter) + */ + distanceFilter: number; + + /** + * IOS, ANDROID ONLY + * Enable this in order to force a stop() when the application terminated + * (e.g. on iOS, double-tap home button, swipe away the app). + */ + stopOnTerminate?: boolean; + + /** + * ANDROID, WP8 ONLY + * The minimum time interval between location updates in seconds. + * @see Android docs (http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(long,%20float,%20android.location.Criteria,%20android.app.PendingIntent)) + * and the MS doc (http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geolocator.reportinterval) + * for more information + */ + locationTimeout?: number; + + /** + * ANDROID ONLY + * Custom notification title in the drawer. + */ + notificationTitle?: string; + + /** + * ANDROID ONLY + * Custom notification text in the drawer. + */ + notificationText?: string; + + /** + * ANDROID ONLY + * The accent color to use for notification. Eg. #4CAF50. + */ + notificationIconColor?: string; + + /** + * ANDROID ONLY + * The filename of a custom notification icon. See android quirks. + * NOTE: Only available for API Level >=21. + */ + notificationIcon?: string; + + /** + * ANDROID ONLY + * Set location service provider @see wiki (https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers) + */ + locationService?: number; + + /** + * IOS ONLY + * [AutomotiveNavigation, OtherNavigation, Fitness, Other] Presumably, + * this affects iOS GPS algorithm. @see Apple docs for more information + * (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/activityType) + */ + activityType?: string; + +} + +/** + * @name BackgroundGeolocation + * @description + * This plugin provides foreground and background geolocation with battery-saving "circular region monitoring" and "stop detection". For + * more detail, please see https://github.com/mauron85/cordova-plugin-background-geolocation + * + * @usage + * + * ```ts + * import {BackgroundGeolocation} from 'ionic-native'; + * + * + * + * // When device is ready : + * platform.ready().then(() => { + * + * // BackgroundGeoLocation is highly configurable. See platform specific configuration options + * BackgroundGeolocation.configure( + * (location) => { + * console.log('[js] BackgroundGeoLocation callback: ' + location.latitude + ',' + location.longitude); + * /* + * IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, + * and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. + * IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. + * */ + * backgroundGeoLocation.finish(); + * }, + * (error) => { + * console.log('BackgroundGeoLocation error'); + * }, + * { + * desiredAccuracy: 10, + * stationaryRadius: 20, + * distanceFilter: 30, + * debug: true, // <-- enable this hear sounds for background-geolocation life-cycle. + * stopOnTerminate: false, // <-- enable this to clear background location settings when the app terminates + * } + * ); + * + * // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app. + * BackgroundGeoLocation.start(); + * } + * + * // If you wish to turn OFF background-tracking, call the #stop method. + * BackgroundGeoLocation.stop(); + * + * ``` + */ +@Plugin({ + plugin: 'cordova-plugin-mauron85-background-geolocation', + pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js + repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation' +}) +export class BackgroundGeoLocation { + + /** + * Configure the plugin. + * Success callback will be called with one argument - 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. + * + * Fail callback to be executed every time a geolocation error occurs. + * + * Options a json object of type BGeoOptions + */ + @Cordova({ + callbackOrder: 'reverse' + }) + static configure(options: BGeoOptions): Promise { return; } + +// /** +// * Get the device's current position. +// * +// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). +// * @return Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error. +// */ +// @Cordova({ +// callbackOrder: 'reverse' +// }) +// static getCurrentPosition(options?: GeolocationOptions): Promise { return; } +// +// /** +// * Watch the current device's position. Clear the watch by unsubscribing from +// * Observable changes. +// * +// * ```ts +// * var subscription = Geolocation.watchPosition().subscribe(position => { +// * console.log(position.coords.longitude + ' ' + position.coords.latitude); +// * }); +// * +// * // To stop notifications +// * subscription.unsubscribe(); +// * ``` +// * +// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). +// * @return Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors. +// */ +// @Cordova({ +// callbackOrder: 'reverse', +// observable: true, +// clearFunction: 'clearWatch' +// }) +// static watchPosition(options?: GeolocationOptions): Observable { return; } +} From 2daca853dcecf4c4d5e37fab26ff67a0914a3cb3 Mon Sep 17 00:00:00 2001 From: vfdev Date: Fri, 13 May 2016 15:58:43 +0200 Subject: [PATCH 2/5] * [DEV] Add some functions * Add plugin in the index.ts --- src/index.ts | 1 + src/plugins/background-geolocation.ts | 86 ++++++++++++++++++++++----- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1d43e9c14..0fbcbffb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,6 +11,7 @@ import {AppAvailability} from './plugins/appavailability'; import {AppRate} from './plugins/apprate'; import {AppVersion} from './plugins/appversion'; import {Badge} from './plugins/badge'; +import {BackgroundGeolocation} from './plugins/background-geolocation'; import {BarcodeScanner} from './plugins/barcodescanner'; import {Base64ToGallery} from './plugins/base64togallery'; import {BatteryStatus} from './plugins/batterystatus'; diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index dd9ebf9f8..f91c07172 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -67,7 +67,7 @@ export interface Location { timestamp: number; } -export interface BGeoOptions { +export interface Config { /** * Desired accuracy in meters. Possible values [0, 10, 100, 1000]. The lower @@ -169,44 +169,44 @@ export interface BGeoOptions { * // When device is ready : * platform.ready().then(() => { * - * // BackgroundGeoLocation is highly configurable. See platform specific configuration options + * // BackgroundGeolocation is highly configurable. See platform specific configuration options * BackgroundGeolocation.configure( * (location) => { - * console.log('[js] BackgroundGeoLocation callback: ' + location.latitude + ',' + location.longitude); + * console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude); * /* * IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, * and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. * IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. * */ - * backgroundGeoLocation.finish(); + * BackgroundGeolocation.finish(); * }, * (error) => { - * console.log('BackgroundGeoLocation error'); + * console.log('BackgroundGeolocation error'); * }, * { * desiredAccuracy: 10, * stationaryRadius: 20, * distanceFilter: 30, - * debug: true, // <-- enable this hear sounds for background-geolocation life-cycle. - * stopOnTerminate: false, // <-- enable this to clear background location settings when the app terminates + * debug: true, // enable this hear sounds for background-geolocation life-cycle. + * stopOnTerminate: false, // enable this to clear background location settings when the app terminates * } * ); * * // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app. - * BackgroundGeoLocation.start(); + * BackgroundGeolocation.start(); * } * * // If you wish to turn OFF background-tracking, call the #stop method. - * BackgroundGeoLocation.stop(); + * BackgroundGeolocation.stop(); * * ``` */ @Plugin({ plugin: 'cordova-plugin-mauron85-background-geolocation', - pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js + pluginRef: 'plugins.backgroundGeolocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation' }) -export class BackgroundGeoLocation { +export class BackgroundGeolocation { /** * Configure the plugin. @@ -218,11 +218,69 @@ export class BackgroundGeoLocation { * * Options a json object of type BGeoOptions */ - @Cordova({ - callbackOrder: 'reverse' - }) +// NOT SURE ABOUT THE TYPE OF RETURNED OBJECT +// https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/src/android/BackgroundGeolocationPlugin.java + @Cordova() static configure(options: BGeoOptions): Promise { return; } + + /** + * Turn ON the background-geolocation system. + * The user will be tracked whenever they suspend the app. + */ + @Cordova() + static start(): boolean { return; } + + + /** + * Turn OFF background-tracking + */ + @Cordova() + static stop(): boolean { return; } + + /** + * Inform the native plugin that you're finished, the background-task may be completed + */ + @Cordova() + static finish(): boolean { return; } + + + /** + * Force the plugin to enter "moving" or "stationary" state + */ + @Cordova() + static changePace(isMoving: boolean): boolean { return; } + + + /** + * Setup configuration + */ + @Cordova() + static setConfig(options: Config): boolean { return; } + +// /** +// * Returns current stationaryLocation if available. null if not +// */ +// @Cordova() +// static getStationaryLocation(): boolean { 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 + */ + @Cordova() + static setConfig(options: Config): boolean { return; } + + + + + + + + + + + // /** // * Get the device's current position. // * From 5c7b7e350f041bb21084d35ef7b7ae27828067b4 Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Sun, 15 May 2016 03:15:51 +0200 Subject: [PATCH 3/5] * Fix plugin insertion in index.ts * Add main functions --- src/index.ts | 2 + src/plugins/background-geolocation.ts | 110 ++++++++++++++------------ 2 files changed, 61 insertions(+), 51 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0fbcbffb7..b5a403a6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,6 +65,7 @@ export { AppRate, AppVersion, Badge, + BackgroundGeolocation, BarcodeScanner, Base64ToGallery, BatteryStatus, @@ -123,6 +124,7 @@ window['IonicNative'] = { AppRate: AppRate, AppVersion: AppVersion, Badge: Badge, + BackgroundGeolocation: BackgroundGeolocation, BarcodeScanner: BarcodeScanner, Base64ToGallery: Base64ToGallery, BatteryStatus: BatteryStatus, diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index f91c07172..453b17469 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -173,11 +173,10 @@ export interface Config { * BackgroundGeolocation.configure( * (location) => { * console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude); - * /* - * IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, - * and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. - * IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. - * */ + * + * // IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished, + * // and the background-task may be completed. You must do this regardless if your HTTP request is successful or not. + * // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background. * BackgroundGeolocation.finish(); * }, * (error) => { @@ -203,7 +202,7 @@ export interface Config { */ @Plugin({ plugin: 'cordova-plugin-mauron85-background-geolocation', - pluginRef: 'plugins.backgroundGeolocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js + pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation' }) export class BackgroundGeolocation { @@ -216,102 +215,111 @@ export class BackgroundGeolocation { * * Fail callback to be executed every time a geolocation error occurs. * - * Options a json object of type BGeoOptions + * Options a json object of type Config */ // NOT SURE ABOUT THE TYPE OF RETURNED OBJECT // https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/src/android/BackgroundGeolocationPlugin.java @Cordova() - static configure(options: BGeoOptions): Promise { return; } + static configure(options: Config): Promise { return; } /** - * Turn ON the background-geolocation system. + * Turn ON the background-geolocation system. * The user will be tracked whenever they suspend the app. */ - @Cordova() + @Cordova() static start(): boolean { return; } /** * Turn OFF background-tracking */ - @Cordova() + @Cordova() static stop(): boolean { return; } + /** * Inform the native plugin that you're finished, the background-task may be completed */ - @Cordova() + @Cordova() static finish(): boolean { return; } /** * Force the plugin to enter "moving" or "stationary" state */ - @Cordova() + @Cordova() static changePace(isMoving: boolean): boolean { return; } /** * Setup configuration */ - @Cordova() + @Cordova() static setConfig(options: Config): boolean { return; } // /** // * Returns current stationaryLocation if available. null if not // */ -// @Cordova() +// @Cordova() // static getStationaryLocation(): boolean { 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 +// */ +// @Cordova() +// static onStationary(options: Config): boolean { 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 + * Check if location is enabled on the device + * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). */ - @Cordova() - static setConfig(options: Config): boolean { return; } + @Cordova() + static isLocationEnabled(): Promise { return; } + /** + * Display device location settings + */ + @Cordova() + static showLocationSettings(): boolean { return; } +// /** +// * +// */ +// @Cordova() +// static watchLocationMode(): boolean { return; } +// /** +// * +// */ +// @Cordova() +// static stopWatchingLocationMode(): boolean { return; } - - - - - +// /** +// * +// */ +// @Cordova() +// static getLocations(): boolean { return; } // /** -// * Get the device's current position. // * -// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). -// * @return Returns a Promise that resolves with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or rejects with an error. // */ -// @Cordova({ -// callbackOrder: 'reverse' -// }) -// static getCurrentPosition(options?: GeolocationOptions): Promise { return; } -// +// @Cordova() +// static deleteLocation(): boolean { return; } + // /** -// * Watch the current device's position. Clear the watch by unsubscribing from -// * Observable changes. // * -// * ```ts -// * var subscription = Geolocation.watchPosition().subscribe(position => { -// * console.log(position.coords.longitude + ' ' + position.coords.latitude); -// * }); -// * -// * // To stop notifications -// * subscription.unsubscribe(); -// * ``` -// * -// * @param {GeolocationOptions} options The [geolocation options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions). -// * @return Returns an Observable that notifies with the [position](https://developer.mozilla.org/en-US/docs/Web/API/Position) of the device, or errors. // */ -// @Cordova({ -// callbackOrder: 'reverse', -// observable: true, -// clearFunction: 'clearWatch' -// }) -// static watchPosition(options?: GeolocationOptions): Observable { return; } +// @Cordova() +// static deleteAllLocations(): boolean { return; } + + +// /** +// * +// */ +// @Cordova() +// static apply(): boolean { return; } + } From 58b351ce13e40b39b6e12eb8ba2362a70630af3d Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Sun, 15 May 2016 04:47:35 +0200 Subject: [PATCH 4/5] * Fix signatures and bugs --- src/plugins/background-geolocation.ts | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index 453b17469..5b296c0f1 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -217,9 +217,9 @@ export class BackgroundGeolocation { * * Options a json object of type Config */ -// NOT SURE ABOUT THE TYPE OF RETURNED OBJECT -// https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/src/android/BackgroundGeolocationPlugin.java - @Cordova() + @Cordova({ + callbackOrder: 'reverse' + }) static configure(options: Config): Promise { return; } @@ -228,35 +228,39 @@ export class BackgroundGeolocation { * The user will be tracked whenever they suspend the app. */ @Cordova() - static start(): boolean { return; } + static start() { } /** * Turn OFF background-tracking */ @Cordova() - static stop(): boolean { return; } + static stop(): Promise { return; } /** * Inform the native plugin that you're finished, the background-task may be completed + * Method implemented for IOS */ @Cordova() - static finish(): boolean { return; } + static finish() { } /** * Force the plugin to enter "moving" or "stationary" state + * Used */ @Cordova() - static changePace(isMoving: boolean): boolean { return; } + static changePace(isMoving: boolean) { } /** * Setup configuration */ - @Cordova() - static setConfig(options: Config): boolean { return; } + @Cordova({ + callbackOrder: 'reverse' + }) + static setConfig(options: Config): Promise { return; } // /** // * Returns current stationaryLocation if available. null if not @@ -273,16 +277,16 @@ export class BackgroundGeolocation { /** * Check if location is enabled on the device - * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). + * @returns {Promise} Returns a promise with int argument that takes values 0, 1 (true). */ @Cordova() - static isLocationEnabled(): Promise { return; } + static isLocationEnabled(): Promise { return; } /** * Display device location settings */ @Cordova() - static showLocationSettings(): boolean { return; } + static showLocationSettings() { } // /** // * @@ -316,10 +320,10 @@ export class BackgroundGeolocation { // static deleteAllLocations(): boolean { return; } -// /** -// * -// */ -// @Cordova() -// static apply(): boolean { return; } + /** + * + */ + @Cordova() + static apply(destination: Config, source: Config): Config { return; } } From d12a99c962ab3abffe1b9d8d92ab5c86d0e1f57d Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Tue, 17 May 2016 23:34:14 +0200 Subject: [PATCH 5/5] * Added Background-geolocation plugin : version to test --- src/plugins/background-geolocation.ts | 103 ++++++++++++++------------ 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/src/plugins/background-geolocation.ts b/src/plugins/background-geolocation.ts index 5b296c0f1..86786a7ac 100644 --- a/src/plugins/background-geolocation.ts +++ b/src/plugins/background-geolocation.ts @@ -228,7 +228,7 @@ export class BackgroundGeolocation { * The user will be tracked whenever they suspend the app. */ @Cordova() - static start() { } + static start(): Promise { return; } /** @@ -240,7 +240,7 @@ export class BackgroundGeolocation { /** * Inform the native plugin that you're finished, the background-task may be completed - * Method implemented for IOS + * NOTE: IOS, WP only */ @Cordova() static finish() { } @@ -248,7 +248,7 @@ export class BackgroundGeolocation { /** * Force the plugin to enter "moving" or "stationary" state - * Used + * NOTE: IOS, WP only */ @Cordova() static changePace(isMoving: boolean) { } @@ -262,22 +262,25 @@ export class BackgroundGeolocation { }) static setConfig(options: Config): Promise { return; } -// /** -// * Returns current stationaryLocation if available. null if not -// */ -// @Cordova() -// static getStationaryLocation(): boolean { return; } + /** + * Returns current stationaryLocation if available. null if not + * NOTE: IOS, WP only + */ + @Cordova() + static 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 -// */ -// @Cordova() -// static onStationary(options: Config): boolean { 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 + */ + @Cordova() + static 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() static isLocationEnabled(): Promise { return; } @@ -288,42 +291,46 @@ export class BackgroundGeolocation { @Cordova() static showLocationSettings() { } -// /** -// * -// */ -// @Cordova() -// static watchLocationMode(): boolean { return; } - -// /** -// * -// */ -// @Cordova() -// static stopWatchingLocationMode(): boolean { return; } - -// /** -// * -// */ -// @Cordova() -// static getLocations(): boolean { return; } - - -// /** -// * -// */ -// @Cordova() -// static deleteLocation(): boolean { return; } - -// /** -// * -// */ -// @Cordova() -// static deleteAllLocations(): boolean { return; } - - /** - * + * 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 */ @Cordova() - static apply(destination: Config, source: Config): Config { return; } + static watchLocationMode(): Promise { return; } + + /** + * Stop watching for location mode changes. + * NOTE: ANDROID only + */ + @Cordova() + static stopWatchingLocationMode() { } + + /** + * Method will return all stored locations. + * Locations are stored when: + * - config.stopOnTerminate is false and main activity was killed + * by the system + * or + * - option.debug is true + * NOTE: ANDROID only + */ + @Cordova() + static getLocations(): Promise { return; } + + /** + * Delete stored location by given locationId. + * NOTE: ANDROID only + */ + @Cordova() + static deleteLocation(locationId: number): Promise { return; } + + /** + * Delete all stored locations. + * NOTE: ANDROID only + */ + @Cordova() + static deleteAllLocations(): Promise { return; } }