Skip to content

Commit

Permalink
feat(BackgroundGeolocation): Update to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Roring authored and Christian Roring committed Sep 20, 2016
1 parent 763ad1b commit 919e8da
Showing 1 changed file with 207 additions and 32 deletions.
239 changes: 207 additions & 32 deletions src/plugins/background-geolocation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Cordova, Plugin } from './plugin';
import {Cordova, Plugin} from './plugin';

declare var window;


export interface Location {

/**
Expand Down Expand Up @@ -104,6 +103,22 @@ export interface Config {
*/
stopOnTerminate?: boolean;

/**

* ANDROID ONLY

* Start background service on device boot.

*
* Defaults to false

*/
startOnBoot?: boolean;

/**

* ANDROID ONLY

* If false location service will not be started in foreground and no notification will be shown.
*
* Defaults to true

*/
startForeground?: boolean;

/**
* ANDROID, WP8 ONLY
* The minimum time interval between location updates in seconds.
Expand Down Expand Up @@ -131,12 +146,19 @@ export interface Config {
*/
notificationIconColor?: string;

/**
* ANDROID ONLY
* The filename of a custom notification icon. See android quirks.
* NOTE: Only available for API Level >=21.
/**

* ANDROID ONLY

* The filename of a custom notification icon. See android quirks.

* NOTE: Only available for API Level >=21.

*/
notificationIconLarge?: string;

/**

* ANDROID ONLY

* The filename of a custom notification icon. See android quirks.

* NOTE: Only available for API Level >=21.

*/
notificationIcon?: string;
notificationIconSmall?: string;

/**
* ANDROID ONLY
Expand All @@ -152,6 +174,52 @@ export interface Config {
*/
activityType?: string;

/**

* IOS ONLY

* Pauses location updates when app is paused

*
* Defaults to true

*/
pauseLocationUpdates?: boolean;

/**

* Server url where to send HTTP POST with recorded locations

* @see https://github.com/mauron85/cordova-plugin-background-geolocation#http-locations-posting

*/
url?: string;

/**

* Server url where to send fail to post locations

* @see https://github.com/mauron85/cordova-plugin-background-geolocation#http-locations-posting

*/
syncUrl?: string;

/**
* Specifies how many previously failed locations will be sent to server at once

*
* Defaults to 100

*/
syncThreshold?: number;

/**

* Optional HTTP headers sent along in HTTP request

*/
httpHeaders?: any;

/**
* IOS ONLY

* Switch to less accurate significant changes and region monitory when in background (default)
*
* Defaults to 100

*/
saveBatteryOnBackground?: boolean;

/**

* Limit maximum number of locations stored into db

*
* Defaults to 10000

*/
maxLocations?: number;
}

/**
Expand Down Expand Up @@ -208,96 +276,157 @@ export interface Config {
})
export class BackgroundGeolocation {

/**

* Set location service provider @see https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers

*
* Possible values:
* ANDROID_DISTANCE_FILTER_PROVIDER: 0,

* ANDROID_ACTIVITY_PROVIDER: 1

*
* @enum {number}

*/
static LocationProvider: {
ANDROID_DISTANCE_FILTER_PROVIDER: number,
ANDROID_ACTIVITY_PROVIDER: number
};

/**
* 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.

*
* Possible values:
* HIGH: 0

* MEDIUM: 10

* LOW: 100

* PASSIVE: 1000
*
* enum {number}

*/
static Accuracy: {
HIGH: number,
MEDIUM: number,
LOW: number,
PASSIVE: number
};

/**

* Used in the switchMode function

*
* Possible values:
* BACKGROUND: 0
* FOREGROUND: 1

*
* @enum {number}

*/
static Mode: {
BACKGROUND: number,
FOREGROUND: number
};

/**
* Configure the plugin.
*
*
* @param {Function} Success callback will be called when background location is determined.
* @param {Function} Fail callback to be executed every time a geolocation error occurs.
* @param {Object} 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.
*/
@Cordova({
sync: true
})
static configure(callback: Function, errorCallback: Function, options: Config): void { return; }

static configure(callback: Function, errorCallback: Function, options: Config): void {
return;
}

/**
* Turn ON the background-geolocation system.
* The user will be tracked whenever they suspend the app.
*/
@Cordova()
static start(): Promise<any> { return; }

static start(): Promise<any> {
return;
}

/**
* Turn OFF background-tracking
*/
@Cordova()
static stop(): Promise<any> { return; }

static stop(): Promise<any> {
return;
}

/**
* Inform the native plugin that you're finished, the background-task may be completed
* NOTE: IOS, WP only
*/
@Cordova()
static finish() { }

static finish() {
}

/**
* Force the plugin to enter "moving" or "stationary" state
* NOTE: IOS, WP only
*/
@Cordova()
static changePace(isMoving: boolean) { }

static changePace(isMoving: boolean) {
}

/**
* Setup configuration
*/
@Cordova({
callbackOrder: 'reverse'
})
static setConfig(options: Config): Promise<any> { return; }
static setConfig(options: Config): Promise<any> {
return;
}

/**
* Returns current stationaryLocation if available. null if not
* NOTE: IOS, WP only
*/
@Cordova()
static getStationaryLocation(): Promise<Location> { return; }
static getStationaryLocation(): Promise<Location> {
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<any> { return; }
static onStationary(): Promise<any> {
return;
}

/**
* Check if location is enabled on the device
* @returns {Promise<number>} Returns a promise with int argument that takes values 0, 1 (true).
* NOTE: ANDROID only
*/
@Cordova()
static isLocationEnabled(): Promise<number> { return; }
static isLocationEnabled(): Promise<number> {
return;
}

/**
* Display app settings to change permissions
*/
@Cordova({ sync: true })
static showAppSettings(): void { }
@Cordova({sync: true})
static showAppSettings(): void {
}

/**
* Display device location settings
*/
@Cordova({ sync: true })
static showLocationSettings(): void { }
@Cordova({sync: true})
static showLocationSettings(): void {
}

/**
* Method can be used to detect user changes in location services settings.
Expand All @@ -306,14 +435,17 @@ export class BackgroundGeolocation {
* NOTE: ANDROID only
*/
@Cordova()
static watchLocationMode(): Promise<boolean> { return; }
static watchLocationMode(): Promise<boolean> {
return;
}

/**
* Stop watching for location mode changes.
* NOTE: ANDROID only
*/
@Cordova()
static stopWatchingLocationMode() { }
static stopWatchingLocationMode() {
}

/**
* Method will return all stored locations.
Expand All @@ -325,20 +457,63 @@ export class BackgroundGeolocation {
* NOTE: ANDROID only
*/
@Cordova()
static getLocations(): Promise<any> { return; }
static getLocations(): Promise<any> {
return;
}

/**

* Method will return locations, which has not been yet posted to server. NOTE: Locations does contain locationId.

*/
@Cordova()
static getValidLocations(): Promise<any> {
return;
}

/**
* Delete stored location by given locationId.
* NOTE: ANDROID only
*/
@Cordova()
static deleteLocation(locationId: number): Promise<any> { return; }
static deleteLocation(locationId: number): Promise<any> {
return;
}

/**
* Delete all stored locations.
* NOTE: ANDROID only
*/
@Cordova()
static deleteAllLocations(): Promise<any> { return; }
static deleteAllLocations(): Promise<any> {
return;
}

/**
* Normally plugin will handle switching between BACKGROUND and FOREGROUND mode itself.
* Calling switchMode you can override plugin behavior and force plugin to switch into other mode.
*
* In FOREGROUND mode plugin uses iOS local manager to receive locations and behavior is affected by option.desiredAccuracy and option.distanceFilter.
* In BACKGROUND mode plugin uses significant changes and region monitoring to receive locations and uses option.stationaryRadius only.

*
* BackgroundGeolocation.Mode.FOREGROUND
* BackgroundGeolocation.Mode.BACKGROUND

*
* NOTE: iOS only
*
* @param {number} See above.

*/
@Cordova()
static switchMode(modeId: number): Promise<any> {
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

*/
@Cordova()
static getLogEntries(limit: number): Promise<any> {
return;
}
}

0 comments on commit 919e8da

Please sign in to comment.