Skip to main content

Usage: Sync health data

Learn about requests quotas and sync strategies.

Health Connect request quota

To maintain optimal system stability and performance, Health Connect imposes rate limits on client connections to the Health Connect API.

It is important for you to understand that every data type in rook-sdk is constructed of multiple health variables like heart rate, steps count, hydration, etc. So when a Sleep Summary is extracted there are multiple calls made to the Health Connect API, and whereas in the last months our efforts have been focused on optimizing and reducing the number of API call required for each data type it's still possible for that limit to be reached, especially while doing multiple extraction in a short amount of time.

Depending on the sync type you chose you must have the following things in mind:

Request quota when syncing data manually

  • Extract summaries once daily: Since summaries collect health data from a previous day, there's no need to extract them more than once per day.
  • Use what you already have: If you are extracting Physical Events you don’t need to extract Heart Rate Events ( Physical) or Oxygenation Events (Physical) as these are already included in the PhysicalEvent object.
  • Only sync the relevant health data for you use case: If you are not interested on individual events and only want to sync the summary of a specific date, just use the sync functions in RookSummaryManager.
  • If you already reached the request quota (a RequestQuotaExceededException is returned) avoid calling any sync function for the next hours so your quota can be recovered.

Request quota when syncing data automatically

HCRookYesterdaySyncManager already takes care of practically all issues and limitations of Health Connect. When the quota is reached, all pending syncs are canceled, and a recovery timestamp is created. Pending syncs will not resume until the user re-opens the app after a few hours.

Sync health data

You can choose between implementing a custom sync process manually or use our automatic implementation which handles everything (except for permissions and userId) for you.

tip

The automatic implementation is faster and easier to integrate and is what most developers need, try to use it before attempting to create a custom sync process.