Fitness Tracker Mobile Application Development
Fitness app — not just step counter and pretty graphs. Behind each sensor — separate API with poll frequency limits, background access policies and permissions that Apple and Google tighten with each release. Native application correctly working with CoreMotion, HealthKit, Google Fit and Health Connect simultaneously — significantly more complex than most mobile categories.
Key Technical Decisions
Which Sensors and Why
| Sensor | iOS API | Android API | Typical Frequency |
|---|---|---|---|
| Accelerometer | CMMotionManager | SensorManager (TYPE_ACCELEROMETER) | 50–100 Hz |
| Gyroscope | CMMotionManager | SensorManager (TYPE_GYROSCOPE) | 50–100 Hz |
| Barometer | CMAltimeter | SensorManager (TYPE_PRESSURE) | 1–10 Hz |
| Step Counter | CMPedometer | StepCounterSensor / Health Connect | Cumulative |
| Heart Rate | HealthKit (from Watch) | Health Connect | By event |
| GPS | CLLocationManager | FusedLocationProviderClient | 1 Hz for tracking |
High-frequency accelerometer polling (100 Hz) in background — direct path to battery drain in 3–4 hours. On iOS CMMotionManager.startDeviceMotionUpdates() with UIBackgroundModes: processing and BGProcessingTask allow batch processing, but background execution limited 30 seconds. On Android WorkManager with ExpeditedWork or Foreground Service with FOREGROUND_SERVICE_TYPE_HEALTH.
CoreMotion and Activity Detection
CMMotionActivityManager.startActivityUpdates() gives ready activities: walking, running, cycling, automotive, stationary. Better than self-analyzing accelerometer for most tasks. But nuance: classification arrives with 5–30 second delay (iOS averages data) and works only with CMMotionActivityManager.isActivityAvailable() — unavailable on some iPod Touch models.
For own step detection algorithm from accelerometer: vertical acceleration peak (Y-axis) with threshold > 1.2g at 50 Hz. Between two peaks minimum 300 ms interval (step frequency max ~3.3 Hz). Basic implementation. Precise algorithm accounts for phone position (pocket/hand/backpack) via CoreML classifier or TensorFlow Lite.
GPS Track Logging
CLLocationManager with desiredAccuracy: kCLLocationAccuracyBest in background requires Always permission and UIBackgroundModes: location. Without it updates stop after 10–15 seconds background. On Android FusedLocationProviderClient with LocationRequest.PRIORITY_HIGH_ACCURACY in Foreground Service.
Problem: urban canyon and tunnels — GPS lost, track breaks. Solution: at horizontalAccuracy > 30 m — don't record point. Dead reckoning based on accelerometer/gyroscope during signal loss — more complex, but gives continuous track.
Track export as GPX: standard XML, each point — <trkpt lat="..." lon="..."> with <ele> and <time>. GPX export/import — de facto standard for compatibility with Garmin, Strava, Komoot.
Health Platform Storage Integration
On iOS all workout records must save via HKWorkout in HealthKit. Without it app doesn't appear in Health and users perceive as bug. HKWorkoutBuilder — correct path: add samples (heart rate, distance, calories) during workout, not batch at end. HKWorkoutRoute — saves GPS track linked to workout.
On Android — Health Connect (androidx.health.connect.client). Write ExerciseSessionRecord with activity type, DistanceRecord, TotalCaloriesBurnedRecord. Important: Health Connect requires license agreement with Google and separate review on Play Store publication if app reads health data.
Background Execution and Battery
Most complex in fitness app — correct background work without killing battery. Principles:
- Don't keep high-frequency sensor active all time — enable only during active workout
- On iOS use
BGAppRefreshTaskfor stats sync (not tracking itself) - Cache data locally in SQLite / Core Data, sync to server batches on workout complete
-
CMPedometerandStepCounterSensor— system step counters, work at OS level without us, only read data
Timeframes
App with basic activities (walking, running, cycling), GPS tracking, HealthKit/Health Connect and stats — 8–14 weeks. With custom activity detection algorithms, ML classification and social features — from 4 months. Estimate after sensor requirements and platform analysis.







