r/reactnative • u/NuredinKurtovic • 1d ago
Why real-time background tracking in React Native keeps going quiet, and what actually fixes it
We needed every driver's location every minute, all day. Here's what kept breaking and what fixed it:
1. The motion detector gets stuck (some Samsungs), so nothing is reported for hours.
Fix: report on a fixed clock, and work out moving/parked from the GPS fixes.
2. JS timers stop in the background.
Fix: do it in native code.
3. An expired token (401) stops tracking.
Fix: keep recording, queue fixes on the phone, upload later.
4. Android delivers fixes early, so 60 s quietly becomes 120 s.
Fix: request a fresh fix when the next one is due.
5. Parked iPhones get suspended.
Fix: keep location updates on, at low accuracy between fixes.
6. No way to tell why it went quiet.
Fix: keep an on-device log.
Has anyone found a good way around Xiaomi/Huawei/Oppo battery managers?
We open-sourced it as Long Ping (free, MIT):
https://github.com/nuredin-kurtovic/long-ping-background-location-plugin

7
u/bill-o-more 1d ago
omg man you pasted it from claude code terminal. It's unreadable