Skip to main content

Manual Sync

Use the sync function to manually trigger synchronization of health summary data. This is useful when you want to ensure the latest data from a specific date or data source is uploaded to ROOK.

info

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.

Sync health data manually

There are 2 types of health data Summaries and Events.

Health DataTimezoneOldest date of retrievalLatest date of retrieval
SummaryUTC29 daysYesterday
EventUTC29 daysToday

Sync summaries

Use sync: (props: SyncProps): Promise<BoolResult> to sync summaries: SLEEP_SUMMARY, PHYSICAL_SUMMARY and BODY_SUMMARY (not including today).

SyncProps

export type SyncProps = {
date?: string;
types?: Array<SummaryType>;
dataSource?: DataSourceType;
};
export type SummaryType =
| 'sleep'
| 'physical'
| 'body'
export type DataSourceType = 
| 'HEALTH_CONNECT'
| 'SAMSUNG'
| 'ALL'

Parameters SyncProps is an object that may include the following optional fields:

date (string) An ISO 8601–formatted date string (e.g., "2025-07-01"). When provided, the function will sync data for the specified date only. If omitted, the function attempts to upload any missing data from the past 30 days.

types (Array<SummaryType>) A list of summary types to sync. If provided alongside a date, only the specified types for that date will be synced. Available values:

'sleep'

'physical'

'body'

dataSource (DataSourceType) dataSource this parameter only works for android with samsung health app, for iOS platform will be ignored Specifies the source of the health data to sync. If not provided, the function defaults to using only HEALTH_CONNECT. Available values:

'HEALTH_CONNECT'

'SAMSUNG'

'ALL' (syncs from both available sources)

Return value Returns a Promise<BoolResult>, which resolves to an object indicating whether the sync was successful.

Behavior Without date: If no date is specified, the function checks for any missing data over the past 30 days and attempts to sync it.

With date and types: Syncs only the specified types for the given date.

Without dataSource: Defaults to syncing from HEALTH_CONNECT only

Sync Events

Use the syncEvents function to manually trigger synchronization of health events data. This is useful when you want to ensure the latest data from a specific date, type of event and data source is uploaded to ROOK.

syncEvents: (props: SyncEventProps): Promise<BoolResult>

export type SyncEventProps = {
date: string;
type: EventType;
dataSource?: DataSourceType;
};

Without dataSource: Defaults to syncing from HEALTH_CONNECT only

export type EventType =
| 'activity'
| 'heart_rate'
| 'oxygenation'
| 'temperature'
| 'blood_pressure'
| 'blood_glucose'
| 'calories'
| 'hydration'
| 'nutrition'
| 'steps'
| 'body_metrics';
import {
RookSummaries,
RookEvents,
} from 'capacitor-rook-sdk';


...
const handleManualSync = async () => {
try {
setSyncing(true);

// This function will be deprecated
// we recommend to use the background synchronization
await RookSummaries.sync({});
await RookEvents.syncEvents({date: dateSelected, type: 'activity'})
} catch (error) {
console.log(error);
} finally {
setSyncing(false);
}
};