writeWeight(record)

Writes a body-weight record to the device’s health store. If needed, presents a permissions prompt to the user to request access to health data first, and then writes the record.

  • record—(Required) A WeightRecord object that represents the weight measurement to write. Provide a value greater than 0 and a valid unit.
  • A resolved promise returns no object.

  • A rejected promise returns a HealthServiceFailure object containing details about the error.

This function writes a single weight record to the device’s health store.

  • When the record is written, the promise resolves with no value. Handle success in a then clause.
  • If an error occurs, the error is returned via a rejected promise. Handle errors in a catch clause.
  • If the user denies permission to write health data, the promise is rejected with a HealthServiceFailure.code value of USER_DENIED_PERMISSION.
  • Permission to write health data is granted separately from permission to read it.

See Also