Skip to main content

Extra: Calories events

Upload and display current day calories.

Introduction​

Calories events not only send current day calories count but also return the data that was sent, you can use this data to update your UI without waiting for the webhook event.

Getting started​

Android configuration​

Go to the main Android configuration section to see the basic configuration.

Logging​

Go to the main Logging section to configure logs.

Usage​

Initialize​

Go to the main Initialize and Update userID sections to initialize.

Permissions​

To use Calories events you will need:

info

In order to generate an event you need at least one of the following permissions Active Calories Burned, Total Calories Burned.

Send calories events​

Retrieve and upload current day calories count of Health Connect.

void syncCaloriesEvents() async {
try {
final syncStatusWithData = await HCRookSyncManager.getTodayCaloriesCount();

switch (syncStatusWithData) {
case Synced(data: final calories):
// Update the UI with calories count
break;
case RecordsNotFound():
// No calories events found
break;
}
} catch (error) {
// Handle error
}
}

Warning: This function contributes to the Health Connect rate limit, don't call it too frequently.