Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
activityRecognitionInterval: 5000,
stopDetectionDelay: 1, // <-- minutes to delay after motion stops before engaging stop-detection system
stopTimeout: 30, // 30 minutes
activityType: 'Other',
// Application config
debug: false, // <-- enable this hear sounds for background-geolocation life-cycle.
forceReloadOnLocationChange: false, // <-- [Android] If the user closes the app **while location-tracking is started** , reboot app when a new location is recorded (WARNING: possibly distruptive to user)
forceReloadOnMotionChange: false, // <-- [Android] If the user closes the app **while location-tracking is started** , reboot app when device changes stationary-state (stationary->moving or vice-versa) --WARNING: possibly distruptive to user)
forceReloadOnGeofence: false, // <-- [Android] If the user closes the app **while location-tracking is started** , reboot app when a geofence crossing occurs --WARNING: possibly distruptive to user)
stopOnTerminate: true, // <-- [Android] Allow the background-service to run headless when user closes the app.
startOnBoot: false // <-- [Android] Auto start background-service in headless mode when device is powered-up.
});
// This handler fires whenever bgGeo receives a location update.
BackgroundGeolocation.on('location', _onLocationChanged);
BackgroundGeolocation.on('motionchange', _onMotionChange);
PushNotificationIOS.addEventListener('localNotification', _onNotification);
AppState.addEventListener('change', _handleAppStateChange);
}
stopDetectionDelay: 1, // <-- minutes to delay after motion stops before engaging stop-detection system
stopTimeout: 30, // 30 minutes
activityType: 'Other',
// Application config
debug: false, // <-- enable this hear sounds for background-geolocation life-cycle.
forceReloadOnLocationChange: false, // <-- [Android] If the user closes the app **while location-tracking is started** , reboot app when a new location is recorded (WARNING: possibly distruptive to user)
forceReloadOnMotionChange: false, // <-- [Android] If the user closes the app **while location-tracking is started** , reboot app when device changes stationary-state (stationary->moving or vice-versa) --WARNING: possibly distruptive to user)
forceReloadOnGeofence: false, // <-- [Android] If the user closes the app **while location-tracking is started** , reboot app when a geofence crossing occurs --WARNING: possibly distruptive to user)
stopOnTerminate: true, // <-- [Android] Allow the background-service to run headless when user closes the app.
startOnBoot: false // <-- [Android] Auto start background-service in headless mode when device is powered-up.
});
// This handler fires whenever bgGeo receives a location update.
BackgroundGeolocation.on('location', _onLocationChanged);
BackgroundGeolocation.on('motionchange', _onMotionChange);
PushNotificationIOS.addEventListener('localNotification', _onNotification);
AppState.addEventListener('change', _handleAppStateChange);
}
geoLocationListener = () => {
BackgroundGeolocation.on('location', (location) => {
//console.log('[event] location: ', location);
if (!location.sample) {
const newCoordinate = {
latitude: location.coords.latitude,
longitude: location.coords.longitude
};
const { distanceTravelled } = this.state;
this.addMarker(location);
this.setState({
distanceTravelled: distanceTravelled + this.calcDistance(newCoordinate),
prevLatLng: newCoordinate,
odometer: (location.odometer / 1000).toFixed(1)
});
}
this.setCenter(location)