iOS: Location.startLocationUpdatesAsync() not working as expected in background state

Please provide the following:

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

I am currently using Location.startLocationUpdatesAsync() to get location data while in the foreground and background. Additionally I am using the “Allow While Using App” authorization for the location permission. All testing is currently being done by building a standalone iOS app.

There are no issues while the app is in the foreground. However, by including showsBackgroundLocationIndicator: true I was under the impression that the location services would remain enabled even while the app is backgrounded. It only takes a couple of seconds for the background indicator to disappear and for the location services to stop working until the app is brought back into the foreground.

The location tracking works correctly if I use the “Always” authorization instead but I believe that is not supposed to be necessary for what I am trying to do. Please correct me if I am wrong.

The actual code that I am using is shown below:

await Location.startLocationUpdatesAsync(LOCATION_UPDATES_TASK, {
  accuracy: Location.Accuracy.BestForNavigation,
  showsBackgroundLocationIndicator: true,
});

I have the following in my app.json file:

{
  "expo": {
    "ios": {
      "infoPlist": {
        "UIBackgroundModes": ["location"],
        "NSLocationWhenInUseUsageDescription": "...",
        "NSLocationAlwaysAndWhenInUseUsageDescription": "...",
        "NSLocationAlwaysUsageDescription": "..."
      },
    },
  },
}

edit: removed a word

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