目录

Managing Personal Information

The following describes how to obtain the user's gender, date of birth, height, and weight defined in Me > Profile in the Huawei Health app.

  • Currently, this capability is supported only on mobile phones, and is not supported on smart watches.
  • The personal information in Profile is to be entered by the user. If the user has linked a body fat scale and authorized the scale to sync data to Profile, the weight will be the value measured by the body fat scale.
Figure 1 Profile

Before using any of the following APIs, make sure that you have both obtained the related scopes from Huawei and been granted the scopes by users. Otherwise, the API calling will fail.

Table 1 Scopes required for obtaining personal information

Data Openness Type

Query API

Scope Requested from Users

Scope Requested from Huawei

(See Applying for Health Service Kit)

Gender

getGender

https://www.huawei.com/healthkit/extend/healthbehavior.read

Scope to read personal information data

Date of birth

getBirthDay

Height

getHeight

Weight

getWeight

Obtaining the Gender

Call getGender to obtain the gender as follows:
import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getGender().then((result) => {
    console.info("getGender success: " + JSON.stringify(result))
}).catch((error) => {
    console.error("getGender Error: " + JSON.stringify(error));
});

[h2]Response parameters

Parameter

Type

Description

result

String

  • Success: The parameter indicates the gender and is of the int type. The options are 0 (female), 1 (male), 2 (confidential), and -1 (not set).
  • Others: error description

Obtaining the Birth Date

Call getBirthDay to obtain the date of birth as follows:
import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getBirthday().then((result) => {
    console.info("getBirthday success: " + JSON.stringify(result))
}).catch((error) => {
    console.error("getBirthday Error: " + JSON.stringify(error));
});

[h2]Response parameters

Parameter

Type

Description

result

String

  • Success: in the format YYYYMMDD. For example, value 19900801 indicates August 1, 1990.
  • Others: error description

Obtaining the Height

Call getHeight to obtain the height as follows:

import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getHeight().then((result) => {
    console.info("getHeight success: " + JSON.stringify(result))
}).catch((error) => {
    console.error("getHeight Error: " + JSON.stringify(error));
});

[h2]Response parameters

Parameter

Type

Description

result

String

  • Success: height (cm)
  • Others: error description

Obtaining the Weight

Call getWeight to obtain the weight as follows:
import {HMSHealthKit} from '@hw-hmscore/hms-js-health'
HMSHealthKit.getWeight().then((result) => {
    console.info("getWeight success: " + JSON.stringify(result))
}).catch((error) => {
    console.error("getWeight Error: " + JSON.stringify(error));
});

[h2]Response parameters

Parameter

Type

Description

result

String

  • Success: weight (kg)
  • Others: error description