How to use the react-native-background-geolocation.stop 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
function _handleAppStateChange(currentAppState) {
  _appState = currentAppState;

  if (currentAppState === 'background') {
    BackgroundGeolocation.start();
  } else if (currentAppState === 'active') {
    BackgroundGeolocation.stop();
  }
}
github devnowcafe / runx / src / screens / Home / index.js View on Github external
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;
                case 'finished':
                    runState = { ...this.state.runState, state: 'finished', finishAt: new Date() };
                    clearInterval(this._interval);
                    BackgroundGeolocation.stop();
                    break;
            }
            await AsyncStorage.setItem(`${Configs.StorageKey}:runstate`, JSON.stringify(runState, null));

            this.setState({ runState })
        }
    }