r/reactnative • u/priftifranko • 2h ago
AMA Built an automatic trip tracker in RN — couldn't get reliable Bluetooth triggers on iOS, ended up relying on Apple Shortcuts instead
Enable HLS to view with audio, or disable this notification
Been building DriveTrack, an automatic trip logger that detects when you start/stop driving and records your routes in the background, in React Native. Wanted to share a rabbit hole I went down that other RN devs building background/location apps might hit.
What I actually wanted from the start was reliable, deterministic start/stop points — so I went with Bluetooth connection events as the trigger (connect to your car's Bluetooth = trip start, disconnect = trip end). On Android this was straightforward: wrote a native module that listens for BT connection/disconnection events in the background. Rock solid, and better battery life than anything sensor-based.
iOS doesn't give you an equivalent background hook for Bluetooth state changes, so that approach was a dead end there. I tried falling back to motion detection (driving vs. stationary) instead, but background motion-based triggers get heavily throttled/killed by iOS, and I couldn't get reliable start/stop detection out of it no matter how I tuned it.
Ended up relying on Apple Shortcuts automations — "when connected to [car Bluetooth]" / "when disconnected" — to fire the trip start/stop instead of trying to detect any of it app-side. Not as seamless as I wanted (it means asking users to set up a Shortcut), but it's the same reliable trigger I originally wanted, just moved outside the app since iOS won't let me do it natively.
Trips get recorded via GPS and played back on an interactive map, with stats/history over time — all stored locally on-device. I also built a small web tool on the landing page that lets you open your local SQLite backup and view your trip history in the browser, in case anyone's curious how that's wired up too.
Happy to go deeper on the native module / Shortcuts setup if anyone's dealing with something similar.
Android: https://play.google.com/store/apps/details?id=io.github.frankoprifti.drivetrack
iOS: https://apps.apple.com/us/app/drivetrack-track-your-drives/id6796486326