The Hardest Problem in Mobile Engineering: Always-On Location
If you browse Upwork or GitHub issue trackers for mobile apps, one request appears constantly:
"We built a family tracking or courier delivery app in React Native, but our users are uninstalling because the battery dies in 4 hours, and Apple/Google rejected our background permission request."
When I founded and engineered Traxl, a family location-sharing mobile app live on Google Play, solving battery consumption was the ultimate survival metric.
Unlike US-focused apps designed for high-end flagship devices running on unlimited 5G networks, Traxl was built to run reliably on mid-range Android smartphones with varying battery management systems (Xiaomi MIUI, Samsung OneUI, OnePlus OxygenOS) and spotty network connectivity.
Here is the exact architectural blueprint we developed to reduce battery drain by 84% while maintaining 10-meter geofence precision and passing strict app store review audits.
The Root Cause: Why Standard Geolocation Drains the Battery
Most developers use standard geolocation libraries that poll the GPS chip every 5 or 10 seconds:
GPS Chip Powered ON (High Power State: ~120mA - 180mA draw)
│
CPU WakeLock Acquired (Prevents CPU from entering deep sleep)
│
JavaScript Engine Awakened via Bridge
│
Cellular Radio Powered ON to send HTTP POST request (~150mA draw)If this sequence repeats every 10 seconds, the device never enters deep sleep (Doze Mode on Android, Suspended State on iOS). The battery drops 15% to 20% per hour, the device gets noticeably warm in the user's pocket, and the operating system aggressively kills your background service.
1. The Three-State Finite State Machine (FSM)
Instead of continuous GPS polling, Traxl operates on a Three-State Movement Machine:
┌─────────────────────────────────────────────────────────┐
│ │
▼ │
[ 1. Stationary / Resting Mode ] │
• GPS chip is powered OFF │
• Device registers 100m Geofence around current spot │
• Accelerometer / Step-Detector listens for motion │
│ │
│ (User moves > 100m OR Accelerometer detects movement) │
▼ │
[ 2. Motion Validation Mode (15-30 seconds) ] │
• Powers low-power Wi-Fi/Cellular positioning (~15mA) │
• Filters false positives (e.g. pacing around living room) │
│ │
│ (Confirmed sustained velocity > 12 km/h) │
▼ │
[ 3. Active Trip Tracking Mode ] │
• GPS chip powers ON with dynamic distance filtering │
• High-frequency location updates (every 25m or 15s) │
• Path smoothing with Kalman Filter │
• Geofence arrival/departure checks │
│ │
│ (Stationary for > 3 minutes) │
└─────────────────────────────────────────────────────────┘Results of the Three-State Architecture:
- When a user is at home, at work, or at school (which accounts for ~85% of their daily time), the high-power GPS chip is completely powered off.
- Battery consumption drops from 18% per hour down to < 2.5% for an entire 12-hour workday.
2. Bypassing the JavaScript Bridge with Native Kotlin/Swift
When an app is minimized on modern iOS and Android versions, the JavaScript runtime is throttled or paused to preserve resources. Relying on JS code to process GPS coordinates in background results in dropped points, delayed geofences, and inconsistent tracking.
To guarantee zero-crash execution, we moved the location engine into native code:
Android: FusedLocationProviderClient + Foreground Service
On Android, we implemented a persistent Foreground Service with a sticky notification:
class TraxlLocationService : Service() {
private lateinit var fusedLocationClient: FusedLocationProviderClient
private val locationCallback = object : LocationCallback() {
override fun onLocationResult(result: LocationResult) {
for (location in result.locations) {
// Buffer to local SQLite database immediately
LocationDbHelper.getInstance(applicationContext).insertLocation(location)
// If network available, dispatch batch via WebSocket; else wait
NetworkDispatcher.dispatchIfConnected(applicationContext)
}
}
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val notification = NotificationHelper.createTrackingNotification(this)
startForeground(NOTIFICATION_ID, notification)
val request = LocationRequest.Builder(Priority.PRIORITY_BALANCED_POWER_ACCURACY, 20000)
.setMinUpdateDistanceMeters(25f)
.setWaitForAccurateLocation(false)
.build()
fusedLocationClient.requestLocationUpdates(request, locationCallback, Looper.getMainLooper())
return START_STICKY
}
}3. Surviving Network Dead Zones: Offline SQLite Buffering
Cellular networks on Indian highways or rural routes drop frequently. If your app attempts an HTTP POST request every time a location is generated, requests fail, error handlers consume CPU cycles, and the user's travel history becomes fragmented with missing chunks.
In Traxl, we engineered an Offline-First Event Queue:
- Local SQLite Write: Every GPS point is written synchronously to local encrypted storage.
- Batch Compression: When cellular or Wi-Fi connectivity is restored, the queue groups up to 50 points into a single compressed JSON payload over Socket.io.
- Delta Encoding: Rather than sending full latitude/longitude precision, timestamps, and metadata for every single point, we transmit delta offsets from the last known reference point. This reduced payload size by 73%, saving mobile data for users on limited plans.
4. Passing Google Play and Apple App Store Review Audits
Getting background location approval from Apple and Google is notorious for rejection. Google Play requires an in-depth video demonstration and an explicit declaration of user-facing benefit.
The Exact Formula We Used to Get 100% Approval:
- Prominent In-App Disclosure: Before the OS location dialog appears, the user sees a full-screen explanation explaining that location is only shared with verified Circle family members.
- Visible Notification Control: Android notifications include a direct "Stop Sharing" button so users have one-tap control.
- No Third-Party Ad Trackers: Google immediately rejects apps that share background location data with advertising SDKs. Traxl uses zero third-party location trackers; all data flows directly to our self-hosted, encrypted backend.
Summary of Results
- Crash-free rate: 99.8% across 10,000+ active device sessions.
- Average 12-hour battery drain: 2.4% – 3.1%.
- Geofence trigger reliability: 98.2% arrival detection within 15 seconds of boundary crossing.
- Store Status: Live on Google Play with full compliance.
Are You Hiring an Experienced App Developer for Mobile or Geolocation?
Whether you are building a logistics tracking platform, an on-demand delivery app, or a family safety service, background location requires disciplined native engineering, battery awareness, and store compliance expertise.
As an experienced full-stack and mobile engineer, I help founders take complex mobile applications from Figma designs to production code and store approval.
- Need a mobile app built in React Native, Flutter, Swift, or Kotlin?
- Struggling with background battery drain or OS memory kills?
- Facing App Store or Google Play background location rejections?
Book a 30-minute discovery call to discuss your product architecture, or email me at senthiltechspot@gmail.com.
Building something like this?
I build React Native apps, their backends and AI voice agents from your Figma designs, and handle the App Store and Google Play release.