transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.63k stars 426 forks source link

Location services stay on when distanceFilter=0 and is_moving=true #260

Closed scottwilson312 closed 5 years ago

scottwilson312 commented 7 years ago

Your Environment

Expected Behavior

I expect that when distanceFilter is set to 0, that location services would remain off while is_moving is true, except for when the location is grabbed every locationUpdateInterval

Actual Behavior

Location services stays on any time is_moving is true and consumes battery.

Steps to Reproduce

  1. Set distanceFilter to 0
  2. Take note of "GPS On" time under Settings->Battery
  3. Drive in car for 40 minutes
  4. GPS On time will increase by 40 minutes

Context

I am trying to get a users location whenever they change location and periodically when they are in transit, with absolute minimal battery drain. Ideally I would like to only use the GPS and have location services on in 2 situations:

(1) the user has gone from is_moving to still and is in a new location (2) periodically while they are moving

Thanks!

christocracy commented 7 years ago

I expect that when distanceFilter is set to 0, that location services would remain off while is_moving is true,

This assumption is incorrect. When the activity-recognition system detects the device is moving, naturally location-services are on.

When activity-recognition system says device is still, stopTimeout is engaged and location-services toggle off after elapsed.

scottwilson312 commented 7 years ago

Thank you for the very fast response. I want to reiterate that this is a great plugin and I've been playing around with it for the past day - the documentation is outstanding.

Is there a need for location-services to be on if you are deciding if a user is moving solely on the ActivityRecognition api and are only grabbing a location based on the assumption that a user is moving and a periodic timer?

christocracy commented 7 years ago

distanceFilter and locationUpdateInterval are merely 2 different ways to throttle locations coming off the radio stream and into the app: distance-based vs time-based.

To use time-based throttling (i.e. locationUpdateInterval), you set distanceFilter: 0.

christocracy commented 7 years ago

Could you please re-phrase this. I don't understand your question.

Is there a need for location-services to be on if you are deciding if a user is moving solely on the ActivityRecognition api and are only grabbing a location based on the assumption that a user is moving and a periodic timer?

scottwilson312 commented 7 years ago

Let me know if I have incorrect understanding of some terms.

Locations-services on means that the app is actively using the GPS and consuming power.

Whether or not a user is_moving is based on the ActivityReocognition api which does not use the GPS.

While is_moving is true, location-services is constantly on (can see the little map marker icon int he status bar).

If we only want a location to be taken every 3 minutes while a user is moving, wouldn't we only want location-services to be turned on every 3 minutes, grab the location, then turn location-services back off for another 2 minutes 59 seconds?

christocracy commented 7 years ago

Locations-services on means that the app is actively using the GPS and consuming power.

Yes

Whether or not a user is_moving is based on the ActivityReocognition api which does not use the GPS.

Correct. Activity Recognition API aggregates accelerometer & gyroscope. Low power; no radios involved.

While is_moving is true, location-services is constantly on (can see the little map marker icon int he status bar).

Correct

If we only want a location to be taken every 3 minutes while a user is moving, wouldn't we only want location-services to be turned on every 3 minutes, grab the location, then turn location-services back off for another 2 minutes 59 seconds?

There is no such mechanism. If you want something like this, it can probably implemented. It might take 5 hours @ $200 / hour.

scottwilson312 commented 7 years ago

Thank you for all the help, Chris. I may contact you in the future.

cfroerup commented 7 years ago

@christocracy As a paying customer - will the feature for timed/fixed location updates while moving be added to the paid version of the plugin?

christocracy commented 7 years ago

@cfroerup I have no plans to implement anything in this thread.