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 ...@@ -21,17 +21,29 @@ The plugin creates the object `window.plugins.backgroundGeoLocation` with the me
A full example could be: A full example could be:
``` ```
var bgGeo = window.plugins.backgroundGeoLocation; var bgGeo = window.plugins.backgroundGeoLocation;
bgGeo.configure(successFn, failFn, {
auth_token: 'asdf23423kjslkfjasdf', var callback = function(location) {
url: '/users/location.json' // HTTP to your server.
}); $.post({
url: 'locations.json',
// Enable background geolocation callback: function() {
bgGeo.start(); // Must inform native plugin the task is complete so it can terminate background-thread and go back to sleep.
bgGeo.finish();
// Disable it }
bgGeo.stop(); })
};
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: ...@@ -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) 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 ## Android
** TODO Brian ## ** TODO Brian ##
......
...@@ -25,10 +25,9 @@ ...@@ -25,10 +25,9 @@
var exec = require("cordova/exec"); var exec = require("cordova/exec");
module.exports = { module.exports = {
configure: function(success, failure, config) { configure: function(success, failure, config) {
if (!config.auth_token || !config.url) { var authToken = config.auth_token || 'BackgroundGeoLocation_auth_token',
console.log("BackgroundGeoLocation requires an auth_token and url to report to the server"); url = config.url || 'BackgroundGeoLocation_url',
} stationaryRadius = config.stationaryRadius || 50, // meters
var stationaryRadius = config.stationaryRadius || 50, // meters
distanceFilter = config.distanceFilter || 500, // meters distanceFilter = config.distanceFilter || 500, // meters
locationTimeout = config.locationTimeout || 60; // seconds locationTimeout = config.locationTimeout || 60; // seconds
...@@ -36,7 +35,7 @@ module.exports = { ...@@ -36,7 +35,7 @@ module.exports = {
failure || function() {}, failure || function() {},
'BackgroundGeoLocation', 'BackgroundGeoLocation',
'configure', 'configure',
[config.auth_token, config.url, stationaryRadius, distanceFilter, locationTimeout]); [authToken, url, stationaryRadius, distanceFilter, locationTimeout]);
}, },
start: function(success, failure, config) { start: function(success, failure, config) {
exec(success || function() {}, 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