@kingstinct/react-native-healthkit 5.1.1 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +37 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![@kingstinct/react-native-healthkit on NPM](https://img.shields.io/npm/v/@kingstinct/react-native-healthkit)](https://www.npmjs.com/package/@kingstinct/react-native-healthkit)
5
5
  ![npm](https://img.shields.io/npm/dt/@kingstinct/react-native-healthkit)
6
6
 
7
- React Native bindings for HealthKit with full TypeScript and Promise support covering almost everything. Keeping TypeScript mappings as close as possible to HealthKit - both in regards to naming and serialization. This will make it easier to keep this library up-to-date with HealthKit as well as browsing the official documentation (and if something - metadata properties for example - is not typed it will still be accessible).
7
+ React Native bindings for HealthKit with full TypeScript and Promise support covering about any kind of data. Keeping TypeScript mappings as close as possible to HealthKit - both in regards to naming and serialization. This will make it easier to keep this library up-to-date with HealthKit as well as browsing [the official documentation](https://developer.apple.com/documentation/healthkit) (and if something - metadata properties for example - is not typed it will still be accessible).
8
8
 
9
9
  | Data Types | Query | Save | Subscribe | Examples |
10
10
  | ----------------------------|:------|:------|:----------|:---------------------------------------|
@@ -15,28 +15,54 @@ React Native bindings for HealthKit with full TypeScript and Promise support cov
15
15
  | Document Types | ✅ | ❌ | ✅ | [CDA documents](https://developer.apple.com/documentation/healthkit/hkcdadocument) exposed as Base64 data |
16
16
  | Clinical Records | ✅ | ❌ | ✅ | Lab results etc in [FHIR JSON format](https://www.hl7.org/fhir/json.html) |
17
17
 
18
+ ## Disclaimer
19
+
20
+ This library is provided without any warranty and is not affiliated with Apple in any way. The data might be incomplete or inaccurate.
21
+
18
22
  ## Installation
19
23
 
24
+ ### Native App
25
+ 1. Install package
20
26
  ```sh
21
- npm install @kingstinct/react-native-healthkit
22
- cd ios
23
- pod install
27
+ yarn add @kingstinct/react-native-healthkit # or npm install @kingstinct/react-native-healthkit
28
+ npx pod-install
24
29
  ```
25
30
 
26
- or
31
+ 2. Remember to set `NSHealthUpdateUsageDescription` and `NSHealthShareUsageDescription` in your `Info.plist`
27
32
 
28
- ```sh
29
- yarn add @kingstinct/react-native-healthkit
30
- cd ios
31
- pod install
33
+ 3. Enable the HealthKit capability for the project in Xcode.
34
+
35
+ 4. Since this package is using Swift you might also need to add a bridging header in your project if you haven't already, you can [find more about that in the official React Native docs](https://reactnative.dev/docs/native-modules-ios#exporting-swift)
36
+
37
+ 5. During runtime you can check if HealthKit is available on the device with `isHealthDataAvailable` and request permissions with `requestAuthorization`. Failing to request authorization will result in the app crashing.
38
+
39
+ ### Expo Managed Workflow
40
+ Usage with Expo is possible - just keep in mind it will not work in Expo Go and [you'll need to roll your own Dev Client](https://docs.expo.dev/development/getting-started/).
41
+
42
+ 1. Install package
43
+ ```sh
44
+ yarn add @kingstinct/react-native-healthkit # or npm install @kingstinct/react-native-healthkit
32
45
  ```
33
46
 
34
- Remember to set `NSHealthUpdateUsageDescription` and `NSHealthShareUsageDescription` in your `Info.plist` as well as enable the HealthKit capability for the project in Xcode. During runtime you need to check if HealthKit is available on the device with `isHealthDataAvailable` and request permissions with `requestAuthorization`. The example has been migrated to **Expo** for easy-of-use and maintainability. See the [example app.json](https://github.com/Kingstinct/react-native-healthkit/blob/8e82d921f57c9bc0912af5f52f53c181ee8e4b5a/example/app.json#L24-L31) for how to apply this to your project. Just keep in mind this will not work in Expo Go since there is native iOS code involved - you'll have to use EAS to [build your own client](https://docs.expo.dev/development/getting-started/).
47
+ 2. See the [example app.json](https://github.com/Kingstinct/react-native-healthkit/blob/8e82d921f57c9bc0912af5f52f53c181ee8e4b5a/example/app.json#L24-L31) for how to apply this to your project.
35
48
 
36
- Since this package is using Swift you might also need to add a bridging header in your project if you haven't already, you can [find more about that in the official React Native docs](https://reactnative.dev/docs/native-modules-ios#exporting-swift)
49
+ 3. During runtime you can check if HealthKit is available on the device with `isHealthDataAvailable` and request permissions with `requestAuthorization`. Failing to request authorization will result in the app crashing.
37
50
 
38
51
  ## Usage
39
52
 
53
+ Some hook examples:
54
+ ```TypeScript
55
+ import { HKQuantityTypeIdentifier, useHealthkitAuthorization } from '@kingstinct/react-native-healthkit';
56
+
57
+ const [authorizationStatus, requestAuthorization] = useHealthkitAuthorization([HKQuantityTypeIdentifier.bloodGlucose])
58
+
59
+ // make sure that you've requested authorization before requesting data, otherwise your app will crash
60
+ import { useMostRecentQuantitySample, HKQuantityTypeIdentifier } from '@kingstinct/react-native-healthkit';
61
+
62
+ const mostRecentBloodGlucoseSample = useMostRecentQuantitySample(HKQuantityTypeIdentifier.bloodGlucose)
63
+ ```
64
+
65
+ Some imperative examples:
40
66
  ```TypeScript
41
67
  import HealthKit, { HKUnit, HKQuantityTypeIdentifier, HKInsulinDeliveryReason, HKCategoryTypeIdentifier } from '@kingstinct/react-native-healthkit';
42
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",