// Do your HTTP request here to POST location to your server.
//
//
yourAjaxCallback.call(this);
};
};
bgGeo.configure(callback, failFn, {
var failureFn = function(error) {
stationaryRadius: 50, // meters
console.log('BackgroundGeoLocation error');
distanceFilter: 50, // meters
}
debug: true // enables sounds for bg-tracking events for debugging.
// BackgroundGeoLocation is highly configurable.
bgGeo.configure(callbackFn, failureFn, {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
debug: true // <-- enable this hear sounds for background-geolocation life-cycle.
});
});
// Enable background geolocation
// Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.
bgGeo.start();
bgGeo.start();
.
// If you wish to turn OFF background-tracking, call the #stop method.
.
// bgGeo.stop()
.
// When you want to stop tracking the user in the background, simply execute
// bgGeo.stop();
```
```
...
@@ -57,7 +84,7 @@ NOTE: The plugin includes `org.apache.cordova.geolocation` as a dependency. You
...
@@ -57,7 +84,7 @@ NOTE: The plugin includes `org.apache.cordova.geolocation` as a dependency. You
## iOS
## iOS
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)
Unfortunately, this plugin is really geared towards use with iOS; The Android implementation is only very basic. 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
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.
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.
...
@@ -66,6 +93,12 @@ Both #distanceFilter and #stationaryRadius can be modified at run-time. For exa
...
@@ -66,6 +93,12 @@ Both #distanceFilter and #stationaryRadius can be modified at run-time. For exa
With aggressive location-monitoring enabled, if the user stops for exactly 15 minutes, iOS will automatically send a signal to the native-plugin which will turn-off standard location services and once again begin region-monitoring (#stationaryRadius) using the iOS significant-changes api.
With aggressive location-monitoring enabled, if the user stops for exactly 15 minutes, iOS will automatically send a signal to the native-plugin which will turn-off standard location services and once again begin region-monitoring (#stationaryRadius) using the iOS significant-changes api.