Building a Fitness Tracker App for iOS and Android
A fitness app is more than a step counter and pretty charts. Behind every sensor is a separate API with sampling rate limits, background access policies, and permissions that Apple and Google tighten with each release. We develop native fitness trackers for iOS and Android that correctly work with CoreMotion, HealthKit, Google Fit, and Health Connect simultaneously — significantly more complex than most other mobile categories. We will evaluate your project in 1 day — contact us for a consultation.
How a Fitness Tracker Works on iOS and Android
Which Sensors and Why
| Sensor | iOS API | Android API | Typical Frequency | Power Consumption (per hour) |
|---|---|---|---|---|
| Accelerometer | CMMotionManager | SensorManager (TYPE_ACCELEROMETER) | 50–100 Hz | 15–20% at 100 Hz |
| Gyroscope | CMMotionManager | SensorManager (TYPE_GYROSCOPE) | 50–100 Hz | 12–18% at 100 Hz |
| Barometer | CMAltimeter | SensorManager (TYPE_PRESSURE) | 1–10 Hz | 3–5% |
| Pedometer | CMPedometer | StepCounterSensor / Health Connect | Cumulative | < 5% |
| Heart Rate | HealthKit (from Watch) | Health Connect | On event | < 2% |
| GPS | CLLocationManager | FusedLocationProviderClient | 1 Hz for tracking | 30–40% during continuous tracking |
High-frequency accelerometer polling (100 Hz) in the background is a direct path to battery drain in 3–4 hours. On iOS, CMMotionManager.startDeviceMotionUpdates() with UIBackgroundModes: processing and BGProcessingTask allows batch processing, but background execution is limited to 30 seconds. On Android, WorkManager with ExpeditedWork or Foreground Service with type FOREGROUND_SERVICE_TYPE_HEALTH. Using the system pedometer CMPedometer reduces power consumption by 40% compared to a custom algorithm.
CoreMotion and Activity Detection
CMMotionActivityManager.startActivityUpdates() provides ready activities: walking, running, cycling, automotive, stationary. This is better than analyzing the accelerometer yourself for most tasks. However, there is a nuance: classification arrives with a 5–30 second delay (iOS averages data) and only works if CMMotionActivityManager.isActivityAvailable() returns true — unavailable on some iPod Touch models.
For a custom step detection algorithm from the accelerometer: peak of vertical acceleration (Y-axis) with threshold > 1.2g at 50 Hz. Minimum interval between two peaks is 300 ms (step frequency no higher than ~3.3 Hz). This is a basic implementation. An accurate algorithm considers phone placement (pocket/hand/backpack) via a classifier using CoreML or TensorFlow Lite — recognition accuracy reaches 95%.
GPS Route Tracking
CLLocationManager with desiredAccuracy: kCLLocationAccuracyBest in the background requires Always permission and UIBackgroundModes: location. Without this, updates stop after 10–15 seconds in background. On Android, FusedLocationProviderClient with LocationRequest.PRIORITY_HIGH_ACCURACY in a Foreground Service.
Problem: urban canyons and tunnels — GPS is lost, track breaks. Solution: when horizontalAccuracy > 30 m — don't record the point. Dead reckoning using accelerometer/gyroscope during signal loss is more complex but provides a continuous track.
Recording the track in GPX format: standard XML, each point is <trkpt lat="..." lon="..."> with <ele> and <time>. GPX export/import is a de facto standard for compatibility with Garmin, Strava, Komoot.
Why Background Execution Is the Main Challenge
The hardest part of a fitness app is correct background operation without killing the battery. Principles:
- Keep high-frequency sensors active only during active workouts
- On iOS, use
BGAppRefreshTaskfor syncing statistics (not for tracking itself) - Cache data locally in SQLite / Core Data, sync with server in batches after workout completion
-
CMPedometerandStepCounterSensorare system pedometers that work at the OS level without our involvement; we only read data
The system pedometer CMPedometer is 3× faster than a custom algorithm and consumes 60% less power. Our 10+ years of mobile development experience allows us to choose the optimal combination of APIs for each task.
Integration with Platform Health Stores
On iOS, all workout records must be saved via HKWorkout in HealthKit. Without this, the app won't appear in the Health app, and users will perceive it as a bug. HKWorkoutBuilder is the right approach: it lets you add samples (heart rate, distance, calories) during the workout, not in a batch at the end. HKWorkoutRoute saves the GPS track linked to the workout.
On Android — Health Connect (androidx.health.connect.client). We write ExerciseSessionRecord with activity type, DistanceRecord, TotalCaloriesBurnedRecord. Important: Health Connect requires a licensing agreement with Google and a separate review when publishing to Play Store if the app reads medical data. Over 50 of our projects have passed this process.
What You Get
As a result, you receive a fully working turnkey application:
- Source code in Swift/Kotlin/Dart with comments
- API and architecture documentation
- Access to App Store and Google Play developer accounts
- Integration with HealthKit/Health Connect and Google Fit
- Push notification setup via APNs/FCM
- 3 months of support after release
- Training for your team on working with the code
Common Mistakes in Fitness Tracker Development
- Ignoring App Store Review policies on HealthKit usage — leads to app rejection
- Lack of graceful degradation when GPS signal is lost — user sees a broken track
- Overly frequent sensor polling in the background — battery drains in 2–3 hours
- Incorrect permission handling (Away/Always) — app crashes or doesn't work in background
- No synchronization with system health stores — users complain about incomplete data
Each of these mistakes has been fixed by us in real projects. We guarantee your app will pass review and won't be rejected for these reasons.
Timeline and Cost
An app with basic activities (walking, running, cycling), GPS tracking, HealthKit/Health Connect, and statistics — 8–14 weeks. With custom activity detection algorithms, ML classification, and social features — from 4 months. Cost is calculated individually based on your requirements. Get a consultation and accurate estimate — contact us.







