Offline First: Introducing TrueTime for Swift and Android
Article Summary
Instacart shoppers were losing minutes in grocery store dead zones. The culprit? You can't trust device clocks when every second counts.
Instacart open sourced TrueTime, an NTP library for Swift and Android that solves a deceptively tricky problem: getting accurate time on mobile devices. This is part one of their offline-first architecture series.
Key Takeaways
- Device clocks drift by minutes despite NTP, users manually adjust time zones
- TrueTime queries NTP servers once at app start, then uses device uptime offset
- Android version includes RxJava extension with parallel requests and automatic retries
- iOS version auto-handles reachability events and supports iOS, macOS, and tvOS
Critical Insight
When you're promising one-hour delivery, you need millisecond precision that survives spotty networks and user clock tampering.