Search code examples
node.jsfirebasereact-nativegeolocation

Handling react-native geolocation update in firebase


I have a react-native application that tracks the user in the background. I also have a Nodejs backend that interacts with firebase. I want to update user location in firebase using react-native geolocation but I'm worried that calling the API every time position changes will be too many calls. How do I handle something like this?


Solution

  • You can either use setInterval to make api call after 5 or 10 seconds or you can calculate the radius that if the user moves 5m or 10m from last updated location then make an api call.