mauron85 / react-native-background-geolocation

Background and foreground geolocation plugin for React Native. Tracks user when app is running in background.
Apache License 2.0
1.33k stars 562 forks source link

How to stop sending locations at short intervals? #534

Closed DIGITALSQUAD closed 3 years ago

DIGITALSQUAD commented 3 years ago

Your Environment

Context

I'm traking locations by post to my server but sometimes devices send locaions some times in a few seconds, though thery are the same latitude and longitude. I set distanceFilter and stationaryRadius, but it does not working? How to send location at a certain interval or when locations changed by a certain distance.

Steps to Reproduce

postLocation(location){
   // Post location to my server
}

BackgroundGeolocation.on('location', (location) => {
   BackgroundGeolocation.startTask(taskKey => {
        // Function to send location
        this.postLocation(location)
        BackgroundGeolocation.endTask(taskKey);
   });
});
DIGITALSQUAD commented 3 years ago

I solved this issue by set last posted time in state and forced not to post before an iterval.