Location.startLocationUpdatesAsync is not a function error

  1. SDK Version: “expo”: “~40.0.0”
  2. Platforms(Android/iOS/web/all): all

I was having an issue with TaskManager + startLocationUpdatesAsync in my app so I created a new expo app with expo init and am trying to use the following code. I still get the same error of Unhandled Rejection (TypeError): ExpoLocation__WEBPACK_IMPORTED_MODULE_3_.default.startLocationUpdatesAsync is not a function
^ This is specifically happening in the WEBAPP

import { StatusBar } from 'expo-status-bar';
import React, { useEffect } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as TaskManager from 'expo-task-manager';
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';

export default function App() {

  useEffect(() => {
    getLocationAsync();
    return () => {
      TaskManager.unregisterAllTasksAsync();
    };
  }, []);

  async function getLocationAsync() {
    let { status } = await Permissions.askAsync(Permissions.LOCATION);
    if (status !== 'granted') {
      console.error('Permission to access location was denied');
      return;
    }   

    const location = await Location.startLocationUpdatesAsync('background-location-task', {
      accuracy: Location.Accuracy.High,
      timeInterval: 3000,
      showsBackgroundLocationIndicator: true,
      foregroundService: {
        notificationTitle: 'helloww bg geoloc',
        notificationBody: 'body teste nofif',
        notificationColor: '#EEE',
      },
    });
    console.log('loc 1', location);
  }

  return (
    <View style={styles.container}>
      <Text>Open up App.tsx to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

TaskManager.defineTask('background-location-task', ({ data, error }) => {
  if (error) {
    return;
  }

  if (data) {
    const { locations } = data;
    console.log("Hello", locations)
  }
})

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },

});

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.