Skip to content

feat: add queryActivitySummaries#358

Open
imikeyi03 wants to merge 5 commits into
kingstinct:masterfrom
imikeyi03:feat/activity-summary-query
Open

feat: add queryActivitySummaries#358
imikeyi03 wants to merge 5 commits into
kingstinct:masterfrom
imikeyi03:feat/activity-summary-query

Conversation

@imikeyi03

@imikeyi03 imikeyi03 commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Adds a minimal queryActivitySummaries(startDate, endDate) API exposing HKActivitySummaryQuery — the per-day Apple activity-ring rollups (move/exercise/stand values and goals), which were previously unreachable from this library even though ActivitySummaryTypeIdentifier is already supported for authorization.

Closes #215.

API

const summaries = await queryActivitySummaries(startDate, endDate)
// → [{ dateYear, dateMonth, dateDay,
//      activeEnergyBurned, activeEnergyBurnedGoal,        // kcal
//      appleExerciseTime, appleExerciseTimeGoal,          // minutes
//      appleStandHours, appleStandHoursGoal,              // count
//      appleMoveTime, appleMoveTimeGoal }]                // minutes (move-minutes mode; 0 otherwise)

Design notes:

  • Dates are returned as calendar components (dateYear/dateMonth/dateDay) rather than a Date, because HKActivitySummary is keyed by DateComponents — converting to a timestamp would impose a timezone assumption on callers. The query inputs are reduced to day granularity in the user's current calendar, which is inherent to HKActivitySummaryQuery.
  • The predicate sets .calendar on both DateComponents (the classic HKActivitySummaryQuery gotcha — without it the query silently returns nothing).
  • New standalone ActivitySummaryModule mirroring the existing per-domain module structure (StateOfMindModule was the exemplar): nitro spec + nitro.json autolinking registration + Swift impl + bindRetypedMethod bindings + UnavailableFnFromModule fallback on non-iOS platforms.

Testing

  • bun codegen, bun typecheck, bun lint, bun run test all green locally.
  • Honest caveat: authored on Linux against Apple's documentation and this repo's module patterns — I could not run the example app on a device. I'd appreciate a maintainer validating the query on hardware; happy to iterate on anything (API shape included) in review.

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4608b7c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kingstinct/react-native-healthkit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: add support for querying Activity Summary objects from HealthKit

1 participant