title: React native expo background location not working
body: <p>I'm newbiee in react native, I'm using expo I'm trying to get user location if app is in the background or killed. I used Taskmanager but I don't why it's not working. when app is running in foreground it is working fine but when app is in background or killed it's not giving me location.</p>
  
  <p>I'm using Location from expo-location </p>
  
  <pre><code>
  const LOCATION_TASK_NAME = "background-location-task";
  
  componentDidMount = async () =&gt; {
  
          this._getLocationAsync();
    };
  
  _getLocationAsync = async () =&gt; {
      try {
        //ask permission of user for location
        let { status } = await Permissions.askAsync(Permissions.LOCATION);
  
        //check the location setting
        const permissionStaatus = await Location.getProviderStatusAsync();
        const newStatus = permissionStaatus.locationServicesEnabled;
  
        //if phone location is disabled
        if (!newStatus) {
          const { navigation } = this.props;
          Alert.alert(
            "Error",
            "Please Turn On you'r Location",
            [
              {
                text: "OK",
                onPress: this.openSetting
              }
            ],
            { cancelable: false }
          );
        }
        // if location setting is enabled
        else {
          //if status is granted or not
          if (status !== "granted") {
            this.setState({
              errorMessage: "Permission to access location was denied"
            });
            return;
          } else {
            await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
              accuracy: Location.Accuracy.Balanced,
              timeInterval: 3000,
              distanceInterval: 1
            });
          }
        }
      } catch (error) {
        let status = await Location.getProviderStatusAsync();
        if (!status.locationServiceEnabled) {
          const { navigation } = this.props;
          navigation.navigate("Site");
          // console.log(error);
        }
      }
    };
  
  
  
  TaskManager.defineTask(LOCATION_TASK_NAME, async ({ data, error }) =&gt; {
    if (error) {
      // Error occurred - check `error.message` for more details.
      return;
    }
   if (data) {
      const { locations } = data;
    const location = locations.map(location =&gt; {
     let newLocation = Location.reverseGeocodeAsync(location.coords)
          .then(data =&gt; {
            data.map(location =&gt; {
              axios.post(
                "http://192.168.0.1/api/account/saveUserLocation",
                location
              );
            })
  
          })
      })
  }
  });
  </code></pre>