Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/kingstinct/react-native-healthkit/llms.txt

Use this file to discover all available pages before exploring further.

getBiologicalSex

Retrieve the user’s biological sex stored in HealthKit. This is a synchronous operation.

Signature

function getBiologicalSex(): BiologicalSex

Returns

biologicalSex
BiologicalSex
The biological sex value as an enum:
  • BiologicalSex.notSet (0) - Not set or unknown
  • BiologicalSex.female (1) - Female
  • BiologicalSex.male (2) - Male
  • BiologicalSex.other (3) - Other

Example

import { getBiologicalSex, BiologicalSex } from '@kingstinct/react-native-healthkit'

const sex = getBiologicalSex()

switch (sex) {
  case BiologicalSex.female:
    console.log('Biological sex: Female')
    break
  case BiologicalSex.male:
    console.log('Biological sex: Male')
    break
  case BiologicalSex.other:
    console.log('Biological sex: Other')
    break
  case BiologicalSex.notSet:
  default:
    console.log('Biological sex: Not set')
    break
}

getBiologicalSexAsync

Asynchronous version of getBiologicalSex. Use this if you need to await the result or want consistency with other async HealthKit operations.

Signature

function getBiologicalSexAsync(): Promise<BiologicalSex>

Returns

biologicalSex
Promise<BiologicalSex>
Promise that resolves to the biological sex value

Example

import { getBiologicalSexAsync, BiologicalSex } from '@kingstinct/react-native-healthkit'

const sex = await getBiologicalSexAsync()

if (sex === BiologicalSex.female) {
  console.log('User is female')
}
Biological sex is a characteristic stored in the user’s HealthKit profile. It cannot be changed by apps and is set by the user in the Health app settings.
You need to request read authorization for characteristics before accessing this data. This is typically done during initial app setup with requestAuthorization.