Menu

1 / 2

Reading Step Counts on iOS and Android with Capacitor

DEV Community: ionic·Robin·5 days ago
#VVDU2H3S
#devtoionic#devto#dev#health#steps
Reading 0:00
15s threshold

Showing a user's daily step count sounds like a one-liner: read the step records for today and add them up. In practice that number comes out higher than the one in the Health app, because the phone, a watch and fitness apps all record the same walk. In this guide, you'll see how to read step counts in a Capacitor app from Apple HealthKit and Health Connect, get today's total and a 7-day chart, and avoid counting steps twice.

Prerequisites

A Capacitor 8 app.

The Capacitor Health plugin . Full disclosure: we build this plugin at Capawesome, and it's part of Capawesome Insiders , a paid subscription. For setup, see the Installation section.

Android : android.permission.health.READ_STEPS declared in your own AndroidManifest.xml , the privacy policy meta-data entry from the plugin docs, and minSdkVersion set to 26.

iOS : the HealthKit capability enabled and NSHealthShareUsageDescription in Info.plist .

Where steps come from

On iOS, steps live in Apple HealthKit; on Android, in Health Connect.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.