devonzuegel / ketchup-club

1 stars 1 forks source link

Expo's location distanceInterval does not seem to be respected #4

Closed elidourado closed 8 months ago

elidourado commented 8 months ago

We are currently using Expo's Location.watchPositionAsync function to monitor for location changes. We are passing {distanceInterval: 2000} as an option that is supposed to limit updates to when the phone has moved at least 2000 meters. However, updates are much more frequent.

Concerns:

If we can't find a fix using the Expo library, we may have to move to native code to handle this issue.

elidourado commented 8 months ago

Note that we are not actually receiving background location yet. We will need to switch to the Location.startLocationUpdatesAsync function when we are ready to do that. So for the time being, there should be no hit to battery life.

elidourado commented 8 months ago

On iOS we'll use Core Location's startMonitoringSignificantLocationChanges(). On Android we can use LocationRequest.Builder's setMinUpdateDistanceMeters and setMinUpdateIntervalMillis methods, setting minimum distance to 500m and minimum update time to 5 minutes. That should create identical behavior on both platforms.

elidourado commented 8 months ago

Closing this for now since we are using native code on iOS and not testing on Android yet. Should be a one-file fix later when we want to support a native implementation on Android.