Step Logger πŸšΆβ€β™‚οΈ

Version Platforms

A Flutter plugin for cross-platform step tracking with background support.

Features

  • πŸ“Š Real-time step counting
  • πŸ”„ Background service for continuous tracking (Android)
  • πŸ“… Historical session data storage
  • πŸ”” Customizable notification
  • πŸ“± Works in foreground and background
  • πŸ”„ Automatic session recovery after app kills

Platform Support

Feature Android iOS
Real-time steps βœ… βœ…
Background tracking βœ… ⚠️ Limited
Session history βœ… βœ…
Step accuracy High High
Battery impact Moderate Low

Android Setup

Permissions βš™οΈ

Add to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<!-- For Android 9+ background execution -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_HEALTH" />

Service declaration

   <service
      android:name="com.transistorsoft.flutter.backgroundfetch.BackgroundFetchService"
      android:permission="android.permission.BIND_JOB_SERVICE"
      android:exported="true" />

  <service
      android:name="id.flutter.flutter_background_service.BackgroundService"
      android:foregroundServiceType="health"/>

  <service
      android:name="com.your.example_app.ForegroundService"
      android:enabled="true"
      android:exported="false" />                  

iOS Setup

Requirements

  1. Add HealthKit entitlement:

    • In Xcode, go to your target's Signing & Capabilities.
    • Click "+" and add HealthKit.
  2. Add these entries to your Info.plist:

<key>NSHealthShareUsageDescription</key>
<string>We need access to HealthKit to track your steps</string>
<key>NSHealthUpdateUsageDescription</key>
<string>We need access to HealthKit to save your step data</string>
<key>UIBackgroundModes</key>
<array>
  <string>fetch</string>
  <string>healthkit</string>
</array>

<!-- Notification-->
<key>NSUserNotificationAlertStyle</key>
<string>alert</string>

iOS Limitations

⚠️ Important iOS Considerations

  1. Background step updates require explicit user permission.

  2. Steps are only recorded when:

    • The app is in the foreground.
    • The user has HealthKit background delivery enabled.
    • The user opens the app periodically (to sync latest data).
  3. Step data accuracy depends on the device

  4. Sessions interrupted by app kills will:

    • Persist tracking state.
    • Recover steps when the app relaunches.
    • Auto-stop sessions older than 12 hours.

Note: iOS does not support true background step tracking services like Android. The plugin uses HealthKit background delivery as a workaround, which depends on system scheduling and user permissions. This means background updates may be delayed or less frequent compared to Android, and step counts are calculated when the app is brought to the foreground.