Trendyol Oct 9, 2020

Location Tracking with React Native

M6 Related OWASP risk: Inadequate Privacy Controls Learn more →

Article Summary

Yusuf Zeren from Trendyol reveals how they solved real-time courier tracking in React Native—a challenge that seems impossible when JavaScript stops running in the background.

Trendyol's fast delivery team needed to track couriers continuously to assign orders to the nearest driver. The solution required native code since JavaScript won't run when apps are backgrounded or closed. After testing free options, they landed on transistorsoft's background geolocation library with surprising results on both iOS and Android.

Key Takeaways

Critical Insight

Real-time location tracking in React Native requires native solutions and careful handling of OS-level permission changes, power modes, and platform differences between iOS and Android.

The article includes actual code snippets for configuration and reveals a critical iOS 13 permission gotcha that could break your entire tracking flow.

About This Article

Problem

Trendyol's courier tracking system used location-based triggers at first, but this approach had a problem. Couriers needed real-time position updates even when they weren't moving, so the company could assign orders accurately and coordinate deliveries properly.

Solution

Yusuf Zeren's team switched to time-based tracking instead. They used transistorsoft's react-native-background-geolocation library to send location data every 60 seconds when couriers were idle, and more frequently when they were moving.

Impact

The new system worked on both iOS and Android, enabling continuous background tracking without issues. The tradeoff is that time-based tracking drains the battery faster than distance-based alternatives.