@infa-toolkit/route-tracking
v1.0.7
Published
Route Tracking gathers GPS information (usually for vehicles) while running in the background to provide a full sequence of the driven route over several hours.
Downloads
3
Maintainers
Readme
infa-route-tracking
Route Tracking gathers GPS information (usually for vehicles) while running in the background to provide a full sequence of the driven route over several hours.
Install
npm install @infa-toolkit/route-tracking
npx cap sync
API
echo(...)
checkPermissions()
requestPermissions()
addListener(string, ...)
getStatus()
start(...)
restore()
stop()
fetch(...)
clear(...)
- Interfaces
- Type Aliases
- Enums
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>
Returns the given value after showing it in the native logging prompt (e.g. LogCat)<br> <i>This is a default plugin method.</i>
| Param | Type |
| ------------- | ------------------------------- |
| options
| { value: string; } |
Returns: Promise<{ value: string; }>
checkPermissions()
checkPermissions() => Promise<PermissionStatus>
Returns the permission status required by the plugin.<br> <i>This is a standard plugin method.</i>
Returns: Promise<PermissionStatus>
requestPermissions()
requestPermissions() => Promise<PermissionStatus>
Requests the permissions required by the plugin and returns the status.<br> <i>This is a standard plugin method.</i>
Returns: Promise<PermissionStatus>
addListener(string, ...)
addListener(eventName: string, listenerFunc: ListenerCallback) => Promise<PluginListenerHandle> & PluginListenerHandle
Add a callback function to react on a native event, even while the hosting application is not showing in the foreground.<br> <i>This is a standard plugin method.</i>
| Param | Type |
| ------------------ | ------------------------------------------------------------- |
| eventName
| string |
| listenerFunc
| ListenerCallback |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
getStatus()
getStatus() => Promise<RouteTrackingServiceStatusResult>
Returns the status of the service.<br>
Returns: Promise<RouteTrackingServiceStatusResult>
start(...)
start(config: RouteTrackingProviderConfiguration) => Promise<void>
Starts the native route tracking daemon.<br> Consider to clear the native storage immediately after starting the tracking to make sure, that the records will not merge with previous tracks.
| Param | Type |
| ------------ | ------------------------------------------------------------------------------------------------- |
| config
| RouteTrackingProviderConfiguration |
restore()
restore() => Promise<void>
Attempts to restore to a running native route tracking daemon.<br> Use this method if your app has crashed during a running session to restore the broadcast receivers, which notify the listeners on each event.
stop()
stop() => Promise<void>
Stops the native route tracking daemon.<br> Consider to continue with <code>fetch()</code> and <code>clear()</code> after stopping was successful to make sure, that all remaining locations will be transferred to the host.
fetch(...)
fetch(limit?: number | undefined) => Promise<RouteTrackingFetchResult>
Requests and returns cached locations from the native storage.<br> The locations will be returned beginning with the oldest entry up to the newest one, ordered by <code>RouteTrackingGeolocation.timestamp</code> ascending.<br> Make sure to delete the locations after successfully storing them to your local host-application by subsequently calling <code>clear()</code>.
| Param | Type | Description |
| ----------- | ------------------- | ---------------------------------------------------------------------------------------------- |
| limit
| number | Maximum number of returned locations at once. If unset, the method returns all stored records. |
Returns: Promise<RouteTrackingFetchResult>
clear(...)
clear(time?: number | undefined) => Promise<void>
Removes all locations from the native storage. If the timestamp is set, only locations with a timestamp lower or equal to the given timestamp will be considered for removal.<br> <i>Use the time of the latest returned location when chaining clear with fetch.</i>
| Param | Type |
| ---------- | ------------------- |
| time
| number |
Interfaces
PermissionStatus
| Prop | Type | Description |
| -------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------ |
| location
| PermissionState | The naming must match the permission alias set up in the plugin´s annotations. |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
RouteTrackingServiceStatusResult
| Prop | Type |
| ---------- | --------------------------------------------------------------------------------- |
| code
| RouteTrackingServiceStatus |
RouteTrackingProviderConfiguration
| Prop | Type | Description | Default |
| -------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------- |
| interval
| number | Set the desired interval of a location request, in milliseconds. | |
| priority
| RouteTrackingPriority | Set the quality of the request. - HIGH_ACCURACY = 100 - BALANCED_POWER_ACCURACY = 102 - LOW_POWER = 104 - NO_POWER = 105 | 100 |
| smallestDisplacement
| number | Set the minimum displacement between location updates in meters. If unset, this criteria is disabled. | null |
RouteTrackingFetchResult
| Prop | Type |
| ----------- | --------------------------------------- |
| items
| RouteTrackingGeolocation[] |
RouteTrackingGeolocation
| Prop | Type | Description |
| ---------------------- | ------------------- | ---------------------------------------------------------------------------------------- |
| latitude
| number | Coordinate latitude value between -90° and 90° |
| longitude
| number | Coordinate longitude value between -180° and 180° |
| altitude
| number | Coordinate altitude value in meters above sea level |
| time
| number | Unix epoch time of this location based on milliseconds since 00:00:00 January 1 1970 UTC |
| speed
| number | Approximate speed in meters per second |
| bearing
| number | Approximate bearing in degrees from 0° (North) over 90° (East) clockwise |
| accuracy
| number | Horizontal coordinate accuracy in meters from the real location |
| speedAccuracy
| number | Speed accuracy in meters per second from the real speed |
| bearingAccuracy
| number | Bearing accuracy in degrees from the real bearing |
| verticalAccuracy
| number | Vertical coordinate accuracy in meters below / above the real altitude |
Type Aliases
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
ListenerCallback
(err: any, ...args: any[]): void
Enums
RouteTrackingServiceStatus
| Members | Value |
| -------------- | -------------- |
| INACTIVE
| 0 |
| ACTIVE
| 1 |
RouteTrackingPriority
| Members | Value |
| ----------------------------- | ---------------- |
| HIGH_ACCURACY
| 100 |
| BALANCED_POWER_ACCURACY
| 102 |
| LOW_POWER
| 104 |
| NO_POWER
| 105 |