Choosing intervals & battery
Long Ping records on a clock. You choose two intervals, and the device decides which one applies from its own fixes:
movingIntervalSec(default 30 s) while moving,parkedIntervalSec(default 180 s) while parked.
Anything from 1 second to 24 hours works. Moving or parked is decided from speed and distance (see Stop detection); motion changes are always recorded immediately, whatever the interval.
Calculator
Section titled “Calculator”Fixes per day
1,020
Upload requests per day
540
Data per day
≈ 907 KB
Battery
Estimate · pending device measurementsAnchor points: moving every 5 s ≈ 5–10 %/h, every 30 s ≈ 3–6 %/h, every 60 s or longer ≈ 1.5–3 %/h (iOS drops to low power between fixes from 60 s); parked every 3 min ≈ 1–2 %/h. Values between anchors are interpolated. Real numbers depend on the phone, signal, screen and the rest of your app.
Your config
await LongPing.configure({
movingIntervalSec: 30,
parkedIntervalSec: 180,
http: {
url: 'https://api.example.com/locations',
uploadIntervalSec: 60,
},
});Starting points
Section titled “Starting points”| Use | Moving | Parked | Upload | Notes |
|---|---|---|---|---|
| Live dispatch, customer ETAs | 5–10 s | 60–180 s | 10–15 s | Plan for in-vehicle charging. |
| Fleet tracking (the defaults) | 30 s | 180 s | 60 s | A good first rollout. |
| Proof of visit, timesheets | 60–120 s | 300–600 s | 300 s | iOS uses its low-power mode between fixes. |
You do not have to get this right up front. Intervals can be changed at runtime with setConfig(), or for a
whole fleet from your server with remote config, without an app release.
What drives the cost
Section titled “What drives the cost”The moving interval, by far. Below about a minute the GPS is effectively on all the time. From 60 s up, iOS drops to a low-power mode between fixes and switches to full accuracy 15 s before the next fix is due. See How iOS background tracking works.
Accuracy. accuracy: 'high' (the default) asks for the best fix the OS can give. 'balanced' and
'low' cost less and are much less precise; for vehicles on roads, 'high' is usually worth it.
Uploads. uploadIntervalSec: 0 (the default) sends a request as soon as each fix is recorded. With a
30 s moving interval that is two requests a minute; with uploadIntervalSec: 60 and batching it is one.
Fewer, larger requests are cheaper on radio time and on your server.
Things you can’t see from here: screen time, navigation apps running alongside, weak signal (the radio works harder), cold weather. Treat any estimate as a range.
Slowing down on low battery
Section titled “Slowing down on low battery”await LongPing.configure({ movingIntervalSec: 10, lowBattery: { belowPct: 20, intervalSec: 60 },});When the phone is not charging and the battery is below belowPct percent, the effective interval
becomes at least intervalSec, for both moving and parked. It switches back as soon as the phone charges or
the level rises. Both fields are required.
Tuning stop detection
Section titled “Tuning stop detection”The parked interval only helps if the device notices it has stopped. The defaults suit vans and cars:
| Key | Default | Raise it when | Lower it when |
|---|---|---|---|
stopTimeoutSec |
300 | Stops are short and you want them to count as moving (traffic, loading bays). | You want the parked clock sooner after arriving. |
stopRadiusM |
75 | GPS drifts a lot where you park (urban canyons, garages). | You need to tell apart stops that are close together. |
movingSpeedMps |
3 | Walking around the vehicle keeps flipping it to moving. | Slow vehicles (bikes, carts) never count as moving. |
disableStopDetection: true keeps the device on the moving clock the whole time.
Start and stop with the shift
Section titled “Start and stop with the shift”The cheapest fix is the one you never take. Call start() when a driver goes on duty and stop() when they
go off duty. stop() keeps the queue and keeps uploading it until it is empty.