How to use the react-native-background-geolocation.start 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 devnowcafe / runx / src / screens / Home / index.js View on Github external
handleRunStateChange = async (state) => {
        if (state) {
            let runState = {};
            switch (state) {
                case 'running':
                    runState = { ...this.state.runState, state: 'running', runAt: new Date() };
                    BackgroundGeolocation.start();
                    this._interval = setInterval(() => {
                        this.setState({ runningDuration: this.state.runningDuration + 1 })
                    }, 1000);
                    break;
                case 'paused':
                    runState = { ...this.state.runState, state: 'paused', pauseAt: new Date() };
                    clearInterval(this._interval);
                    BackgroundGeolocation.stopWatchPosition();
                    break;
                case 'resume':
                    runState = { ...this.state.runState, state: 'running' };
                    BackgroundGeolocation.watchPosition();
                    this._interval = setInterval(() => {
                        this.setState({ runningDuration: this.state.runningDuration + 1 })
                    }, 1000);
                    break;
github City-of-Helsinki / open-city-app / src / helpers / backgroundTask.js View on Github external
function _handleAppStateChange(currentAppState) {
  _appState = currentAppState;

  if (currentAppState === 'background') {
    BackgroundGeolocation.start();
  } else if (currentAppState === 'active') {
    BackgroundGeolocation.stop();
  }
}