Merge pull request #561 from krizroring/master
Extension of the BackgroundGeolocation plugin
This commit is contained in:
commit
c175badab6
@ -1,8 +1,7 @@
|
|||||||
import { Cordova, Plugin } from './plugin';
|
import {Cordova, Plugin} from './plugin';
|
||||||
|
|
||||||
declare var window;
|
declare var window;
|
||||||
|
|
||||||
|
|
||||||
export interface Location {
|
export interface Location {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,6 +103,22 @@ export interface Config {
|
|||||||
*/
|
*/
|
||||||
stopOnTerminate?: boolean;
|
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
|
* ANDROID, WP8 ONLY
|
||||||
* The minimum time interval between location updates in seconds.
|
* The minimum time interval between location updates in seconds.
|
||||||
@ -131,12 +146,19 @@ export interface Config {
|
|||||||
*/
|
*/
|
||||||
notificationIconColor?: string;
|
notificationIconColor?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ANDROID ONLY
|
* ANDROID ONLY
|
||||||
* The filename of a custom notification icon. See android quirks.
|
* The filename of a custom notification icon. See android quirks.
|
||||||
* NOTE: Only available for API Level >=21.
|
* NOTE: Only available for API Level >=21.
|
||||||
*/
|
*/
|
||||||
notificationIcon?: string;
|
notificationIconLarge?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ANDROID ONLY
|
||||||
|
* The filename of a custom notification icon. See android quirks.
|
||||||
|
* NOTE: Only available for API Level >=21.
|
||||||
|
*/
|
||||||
|
notificationIconSmall?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ANDROID ONLY
|
* ANDROID ONLY
|
||||||
@ -152,6 +174,52 @@ export interface Config {
|
|||||||
*/
|
*/
|
||||||
activityType?: string;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -208,13 +276,61 @@ export interface Config {
|
|||||||
})
|
})
|
||||||
export class BackgroundGeolocation {
|
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: any = {
|
||||||
|
ANDROID_DISTANCE_FILTER_PROVIDER: 0,
|
||||||
|
ANDROID_ACTIVITY_PROVIDER: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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: any = {
|
||||||
|
HIGH: 0,
|
||||||
|
MEDIUM: 10,
|
||||||
|
LOW: 100,
|
||||||
|
PASSIVE: 1000
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in the switchMode function
|
||||||
|
*
|
||||||
|
* Possible values:
|
||||||
|
* BACKGROUND: 0
|
||||||
|
* FOREGROUND: 1
|
||||||
|
*
|
||||||
|
* @enum {number}
|
||||||
|
*/
|
||||||
|
static Mode: any = {
|
||||||
|
BACKGROUND: 0,
|
||||||
|
FOREGROUND: 1
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the plugin.
|
* Configure the plugin.
|
||||||
*
|
*
|
||||||
* @param {Function} Success callback will be called when background location is determined.
|
* @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 {Function} Fail callback to be executed every time a geolocation error occurs.
|
||||||
* @param {Object} An object of type Config
|
* @param {Object} An object of type Config
|
||||||
*
|
*
|
||||||
* @return Location object, which tries to mimic w3c Coordinates interface.
|
* @return Location object, which tries to mimic w3c Coordinates interface.
|
||||||
* See http://dev.w3.org/geo/api/spec-source.html#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.
|
* Callback to be executed every time a geolocation is recorded in the background.
|
||||||
@ -224,7 +340,6 @@ export class BackgroundGeolocation {
|
|||||||
})
|
})
|
||||||
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.
|
* Turn ON the background-geolocation system.
|
||||||
* The user will be tracked whenever they suspend the app.
|
* The user will be tracked whenever they suspend the app.
|
||||||
@ -232,14 +347,12 @@ export class BackgroundGeolocation {
|
|||||||
@Cordova()
|
@Cordova()
|
||||||
static start(): Promise<any> { return; }
|
static start(): Promise<any> { return; }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn OFF background-tracking
|
* Turn OFF background-tracking
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@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
|
* Inform the native plugin that you're finished, the background-task may be completed
|
||||||
* NOTE: IOS, WP only
|
* NOTE: IOS, WP only
|
||||||
@ -247,7 +360,6 @@ export class BackgroundGeolocation {
|
|||||||
@Cordova()
|
@Cordova()
|
||||||
static finish() { }
|
static finish() { }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force the plugin to enter "moving" or "stationary" state
|
* Force the plugin to enter "moving" or "stationary" state
|
||||||
* NOTE: IOS, WP only
|
* NOTE: IOS, WP only
|
||||||
@ -255,7 +367,6 @@ export class BackgroundGeolocation {
|
|||||||
@Cordova()
|
@Cordova()
|
||||||
static changePace(isMoving: boolean) { }
|
static changePace(isMoving: boolean) { }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup configuration
|
* Setup configuration
|
||||||
*/
|
*/
|
||||||
@ -290,14 +401,14 @@ export class BackgroundGeolocation {
|
|||||||
/**
|
/**
|
||||||
* Display app settings to change permissions
|
* Display app settings to change permissions
|
||||||
*/
|
*/
|
||||||
@Cordova({ sync: true })
|
@Cordova({sync: true})
|
||||||
static showAppSettings(): void { }
|
static showAppSettings(): void { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display device location settings
|
* Display device location settings
|
||||||
*/
|
*/
|
||||||
@Cordova({ sync: true })
|
@Cordova({sync: true})
|
||||||
static showLocationSettings(): void { }
|
static showLocationSettings(): void { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method can be used to detect user changes in location services settings.
|
* Method can be used to detect user changes in location services settings.
|
||||||
@ -327,6 +438,12 @@ export class BackgroundGeolocation {
|
|||||||
@Cordova()
|
@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.
|
* Delete stored location by given locationId.
|
||||||
* NOTE: ANDROID only
|
* NOTE: ANDROID only
|
||||||
@ -341,4 +458,29 @@ export class BackgroundGeolocation {
|
|||||||
@Cordova()
|
@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; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user