Skip to content

Step data mismatch when syncing from HealthKit in background #414

@Poovit-B

Description

@Poovit-B

Describe the bug
Hi, I'm using react-native-health to sync step data from HealthKit. Everything works fine when I manually trigger the sync in the foreground and specify startDate and endDate. However, when the same logic runs in the background (e.g., scheduled background task), the step data is missing or incomplete.

Here’s a summary of the issue:

✅ Foreground fetch using startDate/endDate: returns correct step data

❌ Background fetch using same date range: returns empty or incorrect data

The time range I’m using:
startDate: "2025-04-07T17:00:00.000Z"
endDate: "2025-04-09T16:59:59.999Z"

Health app shows 796 steps during that time range

My log shows value is []

Is there any known limitation or extra permission needed to access HealthKit data in the background?
Or could this be related to how iOS delays background sync permissions?

Any suggestions or similar experiences would be really helpful!

Thanks 🙏

Screenshots

Image
Image
Image

  • Device: [iPhone13]
  • OS: [IOS 18.3.2]
  • Version [
    react-native-health": "^1.18.0"
    react-native": "0.74.6"
    ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions