react-nativegeolocationlocation-servicesgoogle-location-services

How to track user location in background, react native?


I am using the react-native-geolocation-service package, and everything works like a charm. But now I am required to track a users location both in the foreground and in the background. I was wandering if the watchPosition method supports background location watching or is it just when in the app? and if it doesn't support it, what would be the alternative?

Thanks


Solution

  • I've used it in the past and it's not straightforward. I tried with the package you mentioned and a few others. I've settled up for the react-native-background-geolocation.

    You might encounter problems when switching from the background to the foreground (assuming you also need to track the location in the foreground). They can be fixed by adding a Listener.