Background location not working as expected

Please provide the following:

  1. SDK Version: 42
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I’m having a critical issue with my App , as it relies mainly on the background location .
I’m testing on Real devices Android 10 and 11

1 : startLocationUpdatesAsync doesn’t work on killed state at all .
2 : startLocationUpdatesAsync without a foreground service only works on foreground.
3 : startLocationUpdatesAsync with foreground service works on foreground as well as background , but stops when killing the app .

I can work with Foreground service , the issue is that it’s only compatible with Android 8 +

This part of the code is outside any component

TaskManager.defineTask("locationupdate", async ({ data, error }) => {
  if (error) {
    //  console.log(error.message);
    return;
  }
  // console.log("Updating Location");
  // console.log(locations[0].coords.speed);
  if (data) {
    const { locations } = data;
    updateLocation(
      locations[0].coords.longitude,
      locations[0].coords.latitude,
      922
    );
  }
});

and then this :

  const startLocation = () => {
    Location.startLocationUpdatesAsync("locationupdate", {
      accuracy: Location.Accuracy.BestForNavigation,
      timeInterval: 5000,
      distanceInterval: 0,
      foregroundService : {
        notificationBody : 'test',
        notificationTitle: 'test test'
      },
      showsBackgroundLocationIndicator:true

    });
  };

“expo-location”: “~12.1.2”,
“expo-task-manager”: “~9.2.2”,
“expo-background-fetch”: “~9.2.2”,

Why is there a lot of issues with expo-location ??? i’ve seen a lot of issues on github but they said they fixed them …

Did you have any luck solving this?

On SDK 42 with expo build it’s working fine , so I had to downgrade from sdk43

Is Expo Build different than Expo Go?

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