title: Send Location Updates to Server in Background
body: <p>What is the best way to keep user's location in sync with server,even after the app is terminated?
  here is what I found this far</p>
  <ol>
  <li>using a foreground service. I already tested that but it's battery consuming, and sometimes it's killed when you lock the phone or turn off the screen.</li>
  <li>using work manager. I also tested it, it sends the location every 15 mins,but so unreliable, and it stopped sending after a while.</li>
  <li>Geofencing. I read that Geofencing api gets location updates more often, every couple of minutes or so, but I haven't tested it.</li>
  <li>LocationListener. There is a method called onLocationChanged, but I don't know how would it work in background.</li>
  </ol>
  <p>is there something like a broadcast receiver that will be fired only when location changed by a margin? I think this would be an optimized solution.
  I am building an app that uses a feature similar to facebook nearby friends (which is stopped working long time ago) or something like tinder to display nearby people.
  Currently I need this for android, but I will need it for IOS as well, I am developing a flutter app.</p>