0.0.6 • Published 7 months ago

react-native-healthier v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-native-healthier

The healthiest way to interact with HealthKit in React Native.

Warning: Don't use this yet. The API isn't totally settled yet and the code is a dumpster fire.

Healthier is different than other React Native libraries for Apple Health because Healthier provides an API that closely resembles the native HealthKit API. Ultimately Healthier allows you (when it's finished) to query any HealthKit data without the need to define new data accessor methods.

import Healthier, {QuantityTypeIdentifier, Query, ignite} from 'react-native-healthier';

// Example: read HRV data from HealthKit
async function readHRVData(startDate: Date, limit?: number) {
  const isAvailable = await Healthier.isAvailable();
  if (!isAvailable) return;

  const sampleType = QuantityTypeIdentifier.HeartRateVariabilitySDNN;

  await Healthier.requestAuthorization({
    read: [sampleType],
  });

  const predicate = Query.compoundPredicate({
    type: 'And', 
    subpredicates: [
      Query.predicateForSamples({
        start: startDate
        options: ['StrictStartDate'],
      }),
      Query.predicateForObjectsWithDeviceProperty({
        key: 'Manufacturer',
        value: 'Apple Inc.',
      }),
      Query.predicateForObjectsWithDeviceProperty({
        key: 'Model',
        value: 'Watch',
      }),
      Query.predicateForObjectsWithDeviceProperty({
        key: 'HardwareVersion',
        value: ["Watch4,1", "Watch4,2", "Watch4,3", "Watch4,4"]
      }),
    ]
  });

  const query = Query.sampleQuery({
    sampleType,
    predicate,
    limit, 
    sortDescriptors: [Query.createSortDescriptor('SampleStartDate', true)],
  });

  const data = await Healthier.execute(query);
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.1.0-alpha.41

7 months ago

0.1.0-alpha.42

7 months ago

0.1.0-alpha.40

8 months ago

0.1.0-alpha.39

1 year ago

0.1.0-alpha.30

2 years ago

0.1.0-alpha.32

2 years ago

0.1.0-alpha.31

2 years ago

0.1.0-alpha.34

2 years ago

0.1.0-alpha.33

2 years ago

0.1.0-alpha.36

1 year ago

0.1.0-alpha.35

1 year ago

0.1.0-alpha.38

1 year ago

0.1.0-alpha.37

1 year ago

0.1.0-alpha.29

2 years ago

0.1.0-alpha.23

2 years ago

0.1.0-alpha.25

2 years ago

0.1.0-alpha.24

2 years ago

0.1.0-alpha.27

2 years ago

0.1.0-alpha.26

2 years ago

0.1.0-alpha.28

2 years ago

0.1.0-alpha.22

2 years ago

0.1.0-alpha.21

2 years ago

0.1.0-alpha.20

2 years ago

0.1.0-alpha.19

2 years ago

0.1.0-alpha.18

2 years ago

0.1.0-alpha.17

2 years ago

0.1.0-alpha.16

2 years ago

0.1.0-alpha.15

2 years ago

0.1.0-alpha.14

2 years ago

0.1.0-alpha.13

2 years ago

0.1.0-alpha.12

2 years ago

0.1.0-alpha.11

2 years ago

0.1.0-alpha.10

2 years ago

0.1.0-alpha.9

2 years ago

0.1.0-alpha.8

2 years ago

0.1.0-alpha.7

2 years ago

0.1.0-alpha.6

2 years ago

0.1.0-alpha.5

2 years ago

0.1.0-alpha.4

2 years ago

0.1.0-alpha.3

2 years ago

0.1.0-alpha.2

2 years ago

0.1.0-alpha.1

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.1.0-alpha.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago