目录

Manually Synchronizing Data

Use Cases

The HUAWEI Health app may fail to synchronize data to the cloud in a timely manner. As a result, your app may not obtain the user's latest health and fitness data from the Health Service Kit cloud promptly. To address this issue, we allow users to manually trigger data synchronization once your app obtains their authorization.

OAuth Scope

To apply for the required scopes, go to Data Synchronization > Manual Data Synchronization on the Console of HUAWEI Developers.

Scope Description
https://www.huawei.com/healthkit/huaweihealthdata.cloudsync Allows HUAWEI Health to synchronize personal data to the cloud (based on data synchronization settings in HUAWEI Health).

This scope is available only to enterprise developer accounts.

API Description

API Description
syncAll(): Promise<void> Synchronizes data as proactively triggered by the user.

Before Getting Started

Development Procedure

  1. Import the Health Service Kit functional module and related public modules.

    import { healthStore } from '@kit.HealthServiceKit';
    import { hilog } from '@kit.PerformanceAnalysisKit';
  2. Call syncAll to synchronize data and process the returned result.

    try {
      await healthStore.syncAll();
      hilog.info(0x0000, 'testTag', 'Succeeded in synchronizing data.');
    } catch (err) {
      hilog.error(0x0000, 'testTag', `Failed to synchronize data. Code: ${err.code}, message: ${err.message}`);
    }