Commit c7934369 authored by Chris Scott's avatar Chris Scott

Docs

parent 95e62889
......@@ -21,17 +21,29 @@ The plugin creates the object `window.plugins.backgroundGeoLocation` with the me
A full example could be:
```
var bgGeo = window.plugins.backgroundGeoLocation;
bgGeo.configure(successFn, failFn, {
auth_token: 'asdf23423kjslkfjasdf',
url: '/users/location.json'
});
// Enable background geolocation
bgGeo.start();
// Disable it
bgGeo.stop();
var bgGeo = window.plugins.backgroundGeoLocation;
var callback = function(location) {
// HTTP to your server.
$.post({
url: 'locations.json',
callback: function() {
// Must inform native plugin the task is complete so it can terminate background-thread and go back to sleep.
bgGeo.finish();
}
})
};
bgGeo.configure(callback, failFn, {
stationaryRadius: 50, // meters
distanceFilter: 50 // meters
});
// Enable background geolocation
bgGeo.start();
// Disable it
bgGeo.stop();
```
......@@ -39,6 +51,19 @@ A full example could be:
The iOS implementation of background geolocation uses [CLLocationManager#startMonitoringSignificantLocationChanges](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instm/CLLocationManager/startMonitoringSignificantLocationChanges)
When the app is suspended, the native plugin initiates [region-monitoring](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLRegion_class/Reference/Reference.html#//apple_ref/doc/c_ref/CLRegion), creating a circular-region of radius *#stationaryRadius* meters. Once the monitored-region signals that the user has gone beyond this region, the native-plugin will initiate aggressive location-monitoring
using [standard location services](https://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html). At this time, *#distanceFilter* is in effect, recording a location each time the user travels that distance.
Both #distanceFilter and #stationaryRadius can be modified at run-time. For example, a #distanceFilter of 50m works great for walking-speed, but is probably too low for a car at highway-speed (too many samples). In the future, the native app could possibly intelligently monitor speed and vary #distanceFilter automatically. For now, you must control this manually.
```
bgGeo.setStationaryRadius(100);
bgGeo.setDistanceFilter(500);
```
## Android
** TODO Brian ##
......
......@@ -25,10 +25,9 @@
var exec = require("cordova/exec");
module.exports = {
configure: function(success, failure, config) {
if (!config.auth_token || !config.url) {
console.log("BackgroundGeoLocation requires an auth_token and url to report to the server");
}
var stationaryRadius = config.stationaryRadius || 50, // meters
var authToken = config.auth_token || 'BackgroundGeoLocation_auth_token',
url = config.url || 'BackgroundGeoLocation_url',
stationaryRadius = config.stationaryRadius || 50, // meters
distanceFilter = config.distanceFilter || 500, // meters
locationTimeout = config.locationTimeout || 60; // seconds
......@@ -36,7 +35,7 @@ module.exports = {
failure || function() {},
'BackgroundGeoLocation',
'configure',
[config.auth_token, config.url, stationaryRadius, distanceFilter, locationTimeout]);
[authToken, url, stationaryRadius, distanceFilter, locationTimeout]);
},
start: function(success, failure, config) {
exec(success || function() {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment