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.

getBloodType

Retrieve the user’s blood type stored in HealthKit. This is a synchronous operation.

Signature

function getBloodType(): BloodType

Returns

bloodType
BloodType
The blood type value as an enum:
  • BloodType.notSet (0) - Not set or unknown
  • BloodType.aPositive (1) - A+
  • BloodType.aNegative (2) - A-
  • BloodType.bPositive (3) - B+
  • BloodType.bNegative (4) - B-
  • BloodType.abPositive (5) - AB+
  • BloodType.abNegative (6) - AB-
  • BloodType.oPositive (7) - O+
  • BloodType.oNegative (8) - O-

Example

import { getBloodType, BloodType } from '@kingstinct/react-native-healthkit'

const bloodType = getBloodType()

const bloodTypeNames: Record<BloodType, string> = {
  [BloodType.notSet]: 'Not Set',
  [BloodType.aPositive]: 'A+',
  [BloodType.aNegative]: 'A-',
  [BloodType.bPositive]: 'B+',
  [BloodType.bNegative]: 'B-',
  [BloodType.abPositive]: 'AB+',
  [BloodType.abNegative]: 'AB-',
  [BloodType.oPositive]: 'O+',
  [BloodType.oNegative]: 'O-',
}

console.log('Blood type:', bloodTypeNames[bloodType])

getBloodTypeAsync

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

Signature

function getBloodTypeAsync(): Promise<BloodType>

Returns

bloodType
Promise<BloodType>
Promise that resolves to the blood type value

Example

import { getBloodTypeAsync, BloodType } from '@kingstinct/react-native-healthkit'

const bloodType = await getBloodTypeAsync()

if (bloodType === BloodType.oNegative) {
  console.log('Universal donor blood type')
} else if (bloodType === BloodType.abPositive) {
  console.log('Universal recipient blood type')
} else if (bloodType === BloodType.notSet) {
  console.log('Blood type not set')
} else {
  console.log('Blood type:', bloodType)
}
Blood type 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 Medical ID.
You need to request read authorization for characteristics before accessing this data. This is typically done during initial app setup with requestAuthorization.
Blood type information is often used in medical and emergency contexts. Always handle the notSet case gracefully, as many users may not have entered this information.

Build docs developers (and LLMs) love