How to use the react-native-background-geolocation.on function in react-native-background-geolocation

To help you get started, we’ve selected a few react-native-background-geolocation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github City-of-Helsinki / open-city-app / src / helpers / backgroundTask.js View on Github external
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);
}
github City-of-Helsinki / open-city-app / src / helpers / backgroundTask.js View on Github external
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);
}
github devnowcafe / runx / src / screens / Home / index.js View on Github external
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)