Primary API of the SDK.
Subscribe to changes in motion activity.
callback will be executed each time the activity-recognition system receives an event (
still, on_foot, in_vehicle, on_bicycle, running).
Subscribe to changes in network connectivity.
Fired when the state of the device's network-connectivity changes (enabled -> disabled and vice-versa). By default, the plugin will automatically fire
connectivitychange event with the current state network-connectivity whenever the start method is executed.
Subscribe to changes in plugin State.enabled.
Fired when the plugin's State.enabled changes. For example, executing start and stop will cause the
onEnabledChnage event to fire.
This event is primarily desigend for use with the configuration option stopAfterElapsedMinutes, which automatically executes the plugin's
Subscribe to Geofence transition events.
callback will be called when any monitored geofence crossing occurs.
Subscribe to changes in actively monitored geofences.
Fired when the list of monitored-geofences changed. The BackgroundGeolocation SDK contains powerful geofencing features that allow you to monitor any number of circular geofences you wish (thousands even), in spite of limits imposed by the native platform APIs (20 for iOS; 100 for Android).
The plugin achieves this by storing your geofences in its database, using a geospatial query to determine those geofences in proximity (@see geofenceProximityRadius), activating only those geofences closest to the device's current location (according to limit imposed by the corresponding platform).
When the device is determined to be moving, the plugin periodically queries for geofences in proximity (eg. every minute) using the latest recorded location. This geospatial query is very fast, even with tens-of-thousands geofences in the database.
It's when this list of monitored geofences changes, that the plugin will fire the
Subscribe to location events.
callback will be executed each time the device has changed-state between MOVING or STATIONARY.
Subsribe to state changes in OS power-saving system.
Fired when the state of the operating-system's "Power Saving" mode changes. Your
callback will be provided with a
bool showing whether
"Power Saving" is enabled or disabled. Power Saving mode can throttle certain services in the background, such as HTTP requests or GPS.
Subscribe to changes in device's location-services configuration / authorization.
callback fill be executed whenever a change in the state of the device's Location Services has been detected. eg: "GPS ON", "Wifi only".
Manually toggles the plugin's motion state between stationary and moving.
When provided a value of
true, the plugin will engage location-services and begin aggressively tracking the device's location immediately,
bypassing stationary monitoring.
If you were making a "Jogging" application, this would be your
[Start Workout] button to immediately begin location-tracking. Send
to turn off location-services and return the plugin to the stationary state.
Remove all records in plugin's SQLite database.
Destory the entire contents of plugin's log database.
Email the result of getLog using device's mail client.
Signal completion of startBackgroundTask
Sends a signal to the native OS that your long-running task, addressed by
taskId privided by startBackgroundTask is complete and the OS may proceed
to suspend your application if applicable.
Retrive the count of all locations current stored in the plugin's SQLite datbase.
Retrieves the current Location.
This method instructs the native code to fetch exactly one location using maximum power & accuracy. The native code will persist the fetched location to
its SQLite database just as any other location in addition to POSTing to your configured url.
If an error occurs while fetching the location,
catchError will be provided with an LocationError.
Fetch a list of all Geofence in the SDK's database. If there are no geofences being monitored, you'll receive an empty
Retrive a List of Location currently stored in the plugin's SQLite datbase.
Returns the entire contents of the log database.
Retrieve the current distance-travelled ("odometer").
The plugin constantly tracks distance travelled, computing the distance between the current location and last and maintaining the sum. To fetch the current odometer reading:
Fetches the state of the operating-system's "Power Saving" mode.
Signal to the plugin that your app is launched and ready, proving the default Config.
The supplied Config will be applied only at first install of your app — for every launch thereafter, the plugin will automatically load its last-known configuration from persisent storage. The plugin always remembers the configuration you apply to it.
:false. * The received
event object contains a
name (the event name) and
params (the event data-object).
registerHeadlessTaskin your application root file (eg:
Alias for removeListeners
Destroy all Geofence.
Removes an event listener. You must supply the type of event to remove in addition to a reference to the exact function you used to subscribe to the event.
Removes all event-listeners
The supplied Config will be appended to the current configuration and applied in realtime.
Enable location + geofence tracking.
This is the plugin's power ON button. The plugin will initially start into its stationary state, fetching an initial location before turning off location services. Android will be monitoring its Activity Recognition System while iOS will create a stationary geofence around the current location.
If you've configured a schedule, this method will override that schedule and engage tracking immediately.
Sends a signal to iOS that you wish to perform a long-running task.
Engages the geofences-only State.trackingMode.
Initiate the configured schedule.
To halt scheduled tracking, use stopSchedule.
Stop watch-position updates initiated from watchPosition.
Manually execute upload to configured url
If the plugin is configured for HTTP with an url and autoSync
false, the sync method will initiate POSTing the locations
currently stored in the native SQLite database to your configured url. When your HTTP server returns a response of
200 OK, that record(s)
in the database will be DELETED.
If you configured batchSync
true, all the locations will be sent to your server in a single HTTP POST request, otherwise the plugin will
execute an HTTP post for each Location in the database (REST-style). Your callback will be executed and provided with a
List of all the
locations from the SQLite database. If you configured the plugin for HTTP (by configuring a url, your callback will be executed after all
the HTTP request(s) have completed. If the plugin failed to sync to your server (possibly because of no network connection), the failure callback will
be called with an error message. If you are not using the HTTP features, sync will delete all records from its SQLite datbase.
The test server is a great way to debug location problems, since the results can easily be shared with Transistor Software when requesting support.
Start a stream of continuous location-updates. The native code will persist the fetched location to its SQLite database just as any other location (If the SDK is currently enabled) in addition to POSTing to your configured url (if you've enabled the HTTP features).
watchPosition is not reccommended for long term monitoring in the background — It's primarily designed for use in the foreground only. You might use it for fast-updates of the user's current position on the map, for example.
The SDK's primary Philosophy of Operation does not require
watchPosition will continue to run in the background, preventing iOS from suspending your application. Take care to listen to
suspend event and call stopWatchPosition if you don't want your app to keep running in the background, consuming battery.
Generated using TypeDoc