Android: get location as Foreground Service (without accessing background location)

  1. SDK Version:40
  2. Platforms(Android/iOS/web/all): Android

Due to the recent changes in Google Play Store regarding background location permissions, I am trying to get our app to conform to the new guidelines (Requesting access to location in the background - Play Console Help). The app is an activity tracker that tracks where the user has been between pressing “record” and “stop”, similar to fitness trackers like Strava.

Naturally I’d like the location updates to keep coming even if the app is not in focus, and I don’t mind a foreground service notification saying that my app is tracking the location. As far as I can see from the new guidelines, they want these kinds of apps to not ask for background location permissions, and instead use a foreground service (that will keep the app in a foreground state, so the location updates will keep coming). I can’t seem to make this work with Expo. I have tried two approaches:

1: use startLocationUpdatesAsync with the foregroundService property - this now fails because in order to use this method, I need to request BACKGROUND_LOCATION permission, which is exactly what I do not want to do.
2: use watchPositionAsync, but that only works when app is focused, and I can’t see any way to make a foregroundService.

Does anyone know if I can somehow achieve getting location updates from an app with a foreground service without asking for BACKGROUND_LOCATION permission? Any help would be greatly appreciated.

1 Like