transistorsoft / nativescript-background-geolocation-lt

Sophisticated, battery-conscious, cross-platform background-geolocation with motion-detection and geofencing
MIT License
73 stars 24 forks source link

Advice for distance and time interval #69

Open randy-johnson opened 7 years ago

randy-johnson commented 7 years ago

Your Environment

I am wondering what config options I would use to have the app communicate every 50 meters and then perhaps every 15 minutes if the app doesn't move more than 50 meters?

I have distanceFilter: 50,

I was thinking maybe this: locationUpdateInterval but the docs make it sound like distanceFilter has to be 0.

heartbeat interval sounds like it could be a possibly too.

Thank You,

Randy

randy-johnson commented 7 years ago

@christocracy, pinging you on this since it has been a couple days. Thank You

christocracy commented 7 years ago

distanceFilter: 50, heartbeatInterval: 60*15}. Listen to heartbeat event.

Simulator is not the best way to test the plugin. The plugin relies on accelerometer-based Motion-detection APIs to decide when to start recording locations. Simulators don't have accelerometers.

If you want the plugin to record locations in Simulator, you have to manually tell the plugin to change to "moving" state with changePace(true).

randy-johnson commented 7 years ago

Thank you. I was able to use a batch file script using genyshell.exe to feed latitude and longitude to the emulator along with the ChangePace(true) to simulate movement.

randy-johnson commented 6 years ago

@christocracy,

I wanted to follow up on this. This configuration works awesome in Android but not IOS.

        desiredAccuracy: 0,
        distanceFilter: 50,
        heartbeatInterval: 60*15,
        foregroundService: false,

I have 2 questions:

  1. Will the above configuration still allow the ios app to communicate on distance changes when the app is minimized? Currently my app only seems to be communicating with my server when the app is open so I want to make sure I am not missing some config settings here.

  2. I was reading in the docs that in order to use heartbeat interval on IOS that I have to use preventSuspend = true which is a bad idea because of battery. Does IOS ignore the setting since I am not using preventSuspend?

Thank You,

christocracy commented 6 years ago

There is no heartbeat on iOS without preventSuspend.

When iOS app is placed in background while in stationary state, iOS has suspended your app.

When the iOS device moves about 200 meters beyond last know location, iOS will awaken your app, the plugin will turn on location services and your app is now completely alive in background (just as if it was running in foreground). It will stay alive, recording a location each distanceFilter meters until the device is detected to have become stationary, when the plugin will initiate the stopTimeout timer. When stopTimeout elapses, the plugin will turn off location-services and iOS will immediately put your app to sleep. And the whole cycle begins again.

DeejayEaster commented 1 year ago

There is no heartbeat on iOS without preventSuspend.

When iOS app is placed in background while in stationary state, iOS has suspended your app.

When the iOS device moves about 200 meters beyond last know location, iOS will awaken your app, the plugin will turn on location services and your app is now completely alive in background (just as if it was running in foreground). It will stay alive, recording a location each distanceFilter meters until the device is detected to have become stationary, when the plugin will initiate the stopTimeout timer. When stopTimeout elapses, the plugin will turn off location-services and iOS will immediately put your app to sleep. And the whole cycle begins again.

So, anytime I lock my iphone, distanceFilter is no longer being respected? Is this why? I am still getting GPS captures, just not with the accuracy my config suggests. From my understanding preventSuspend only affects heartbeatInterval, but without preventSuspend my gps does not capture at the correct intervals.

christocracy commented 1 year ago

So, anytime I lock my iphone, distanceFilter is no longer being respected?

The plug-in doesn’t care if your phone is locked. If the device moves at least 200 meters, the plug-in begins tracking, even if your phone is locked and in your pocket.

but without preventSuspend my gps does not capture at the correct intervals.

The plug-in does not require preventSuspend to operate. You just need to go outside and move at least 200 meters.