authQuantityReadPermissionsSync(params: Object)

Requires:
HealthKit≥5.18.3@ray-js/ray≥1.6.17
Platforms:
iOS

Description

Request read permission for Quantity data types [iOS only]

Parameters

PropertyTypeRequiredDescriptionHealthKit Since
permissionsstring[]NoPermission types (used by the API that requests read/write permissions). See the enum list below for values. e.g. ["1","2"]v5.18.0
readPermissionsstring[]NoRead permission types (used by the API that checks whether the user has granted authorization). See the enum list below for values. e.g. ["1","2"]v5.18.0
writePermissionsstring[]NoWrite permission types (used by the API that checks whether the user has granted authorization). See the enum list below for values. e.g. ["1","2"]v5.18.0
writePermissionnumberNoWrite permission types (used by the API that checks for write permission). See the enum list below for values.v5.18.0
valuenumberNoValue to write (the specific measurement for Quantity or Category data).v5.18.0
unitTypestringNoUnit to pass in, e.g., "mg/dL", "g", "cm", "count"; required when reading or writing Quantity data. For the units corresponding to each data type, refer to Apple's official HKTypeIdentifiers.h file.v5.18.0
startTimenumberNoStart time, timestamp in seconds.v5.18.0
endTimenumberNoEnd time, timestamp in seconds.v5.18.0
typenumberNoData types to read/write (used by the data read/write APIs). See the enum list below for values.v5.18.0

Return Value

None

Error Code

Error CodeError Message
1AppleHealthParamsError

Examples

Request read permission for weight data

import { health } from '@ray-js/ray'

const endTime = Math.floor(Date.now() / 1000);
const startTime = endTime - 60 * 60;

health.authQuantityReadPermissions({
  permissions: ["4"],
  readPermissions: ["4"],
  writePermissions: ["4"],
  writePermission: 4,
  value: 65.5,
  unitType: "kg",
  startTime,
  endTime,
  type: 4,
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});