How to use the expo-location.hasStartedLocationUpdatesAsync function in expo-location

To help you get started, we’ve selected a few expo-location 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 flow-typed / flow-typed / definitions / npm / expo-location_v5.x.x / flow_v0.104.x- / test_expo-location.js View on Github external
it('should passes when used properly', () => {
    hasStartedLocationUpdatesAsync('taskName').then(result => {
      (result: boolean);

      // $ExpectError: check any
      (result: string);
    });
  });
github flow-typed / flow-typed / definitions / npm / expo-location_v5.x.x / flow_v0.104.x- / test_expo-location.js View on Github external
it('should raise an error when call function with invalid arguments', () => {
    // $ExpectError: need a string
    hasStartedLocationUpdatesAsync(69);
  });
});
github expo / expo / apps / native-component-list / src / screens / Location / BackgroundLocationMapScreen.tsx View on Github external
const { status } = await Permissions.askAsync(Permissions.LOCATION);

    if (status !== 'granted') {
      AppState.addEventListener('change', this.handleAppStateChange);
      this.setState({
        // tslint:disable-next-line max-line-length
        error: 'Location permissions are required in order to use this feature. You can manually enable them at any time in the "Location Services" section of the Settings app.',
      });
      return;
    } else {
      this.setState({ error: undefined });
    }

    const { coords } = await Location.getCurrentPositionAsync();
    const isTracking = await Location.hasStartedLocationUpdatesAsync(LOCATION_UPDATES_TASK);
    const task = (await TaskManager.getRegisteredTasksAsync()).find(
      ({ taskName }) => taskName === LOCATION_UPDATES_TASK
    );
    const savedLocations = await getSavedLocations();
    const accuracy = (task && task.options.accuracy) || this.state.accuracy;

    this.eventSubscription = locationEventsEmitter.addListener('update', (locations: any) => {
      this.setState({ savedLocations: locations });
    });

    if (!isTracking) {
      alert('Click `Start tracking` to start getting location updates.');
    }

    this.setState({
      accuracy,
github expo / expo / home / screens / LocationDiagnosticsScreen.js View on Github external
didFocus = async () => {
    let { status } = await Permissions.askAsync(Permissions.LOCATION);

    if (status !== 'granted') {
      AppState.addEventListener('change', this.handleAppStateChange);
      this.setState({
        error:
          'Location permissions are required in order to use this feature. You can manually enable them at any time in the "Location Services" section of the Settings app.',
      });
      return;
    } else {
      this.setState({ error: null });
    }

    const { coords } = await Location.getCurrentPositionAsync();
    const isTracking = await Location.hasStartedLocationUpdatesAsync(LOCATION_UPDATES_TASK);
    const task = (await TaskManager.getRegisteredTasksAsync()).find(
      ({ taskName }) => taskName === LOCATION_UPDATES_TASK
    );
    const savedLocations = await getSavedLocations();

    this.eventSubscription = locationEventsEmitter.addListener('update', locations => {
      this.setState({ savedLocations: locations });
    });

    if (!isTracking) {
      alert('Click `Start tracking` to start getting location updates.');
    }

    this.setState(state => ({
      accuracy: (task && task.options.accuracy) || state.accuracy,
      isTracking,