michalchudziak / react-native-geolocation

Geolocation APIs for React Native
MIT License
1.34k stars 235 forks source link

Android background geolocation #255

Open dukvanduken opened 1 year ago

dukvanduken commented 1 year ago

Hi there! I tried to find free solution for background location for Android RN app and used this react-native-geolocation lib.

But it seems it not support background geolocation. I used this code: ` useEffect(() => { Geolocation.setRNConfiguration({ skipPermissionRequests: false, locationProvider: 'android', })

Geolocation.watchPosition(
  ({ coords: { latitude: lat, longitude: lon }}) => {
    // my code here...
  },
  (error) => console.error(error),
  { interval: 1000, enableHighAccuracy: true, distanceFilter: 1 },
)

}, []) `

It works fine but only app is in focus. Backgrounded app do not watch for position.

I saw this module https://github.com/transistorsoft/react-native-background-geolocation but it's paid and I want to use this lib.

Do I have any possibilities to get background location?

GabrielDuarteJr commented 1 year ago

+1

JB712 commented 1 year ago

Also interested ✋

DeveloperMCD commented 1 year ago

I need this as well!

JB712 commented 1 year ago

A workaround is provided in PR #247, if you want to patch it by yourself

thtRajasthaniGuy commented 1 year ago

+1

michalchudziak commented 1 year ago

I'll try to work on this feature when I'll have some spare time :)

NgVSang commented 1 year ago

+1

quan118 commented 1 month ago

I've just created a fork that includes support for background location updates: https://github.com/quan118/react-native-geolocation