react-native-health-connect 2.0.2 → 2.1.0
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.
package/README.md
CHANGED
|
@@ -19,19 +19,22 @@ This library is a wrapper around Health Connect for react native. Health Connect
|
|
|
19
19
|
|
|
20
20
|
## Requirements
|
|
21
21
|
|
|
22
|
+
Make sure you have React Native version 0.71 or higher installed to use v2 of React Native Health Connect.
|
|
23
|
+
|
|
22
24
|
- [Health Connect](https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata&hl=en&gl=US) needs to be installed on the user's device. Starting from Android 14 (Upside Down Cake), Health Connect is part of the Android Framework. Read more [here](https://developer.android.com/health-and-fitness/guides/health-connect/develop/get-started#step-1).
|
|
23
25
|
- Health Connect API requires `minSdkVersion=26` (Android Oreo / 8.0).
|
|
24
|
-
- If you are planning to release your app on Google Play, you will need to submit a [declaration form](https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true).
|
|
26
|
+
- If you are planning to release your app on Google Play, you will need to submit a [declaration form](https://docs.google.com/forms/d/1LFjbq1MOCZySpP5eIVkoyzXTanpcGTYQH26lKcrQUJo/viewform?edit_requested=true). Approval can take up to 7 days.
|
|
27
|
+
- Approval does not grant you immediate access to Health Connect. A whitelist must propagate to the Health Connect servers, which take an additional 5-7 business days. The whitelist is updated every Monday according to Google Fit AHP support.
|
|
25
28
|
|
|
26
29
|
## Installation
|
|
27
30
|
|
|
28
31
|
To install react-native-health-connect, use the following command:
|
|
29
32
|
|
|
30
33
|
```bash
|
|
31
|
-
|
|
34
|
+
npm install react-native-health-connect
|
|
32
35
|
```
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
If you are using React Native CLI template, for version 2 onwards, please add the following code into your `MainActivity.kt` within the `onCreate` method:
|
|
35
38
|
|
|
36
39
|
```diff
|
|
37
40
|
package com.healthconnectexample
|
|
@@ -66,6 +69,7 @@ class MainActivity : ReactActivity() {
|
|
|
66
69
|
|
|
67
70
|
```
|
|
68
71
|
|
|
72
|
+
You also need to setup permissions in your `AndroidManifest.xml` file. For more information, check [here](https://matinzd.github.io/react-native-health-connect/docs/permissions).
|
|
69
73
|
|
|
70
74
|
## Expo installation
|
|
71
75
|
|
|
@@ -75,7 +79,7 @@ Just add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the
|
|
|
75
79
|
First install the package with yarn, npm, or [`expo install`](https://docs.expo.io/workflow/expo-cli/#expo-install).
|
|
76
80
|
|
|
77
81
|
```sh
|
|
78
|
-
|
|
82
|
+
npm install expo-health-connect expo-build-properties --save-dev
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
Then add the prebuild [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:
|
|
@@ -83,7 +87,7 @@ Then add the prebuild [config plugin](https://docs.expo.io/guides/config-plugins
|
|
|
83
87
|
```json
|
|
84
88
|
{
|
|
85
89
|
"expo": {
|
|
86
|
-
"plugins": ["
|
|
90
|
+
"plugins": ["expo-health-connect"]
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
```
|
package/android/build.gradle
CHANGED
|
@@ -46,6 +46,7 @@ android {
|
|
|
46
46
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
47
47
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
48
48
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
49
|
+
consumerProguardFiles "proguard-rules.pro"
|
|
49
50
|
}
|
|
50
51
|
buildTypes {
|
|
51
52
|
release {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-keep class dev.matinzd.healthconnect.records.** { *; }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
package dev.matinzd.healthconnect.permissions
|
|
2
2
|
|
|
3
|
+
import androidx.activity.ComponentActivity
|
|
3
4
|
import androidx.activity.result.ActivityResultLauncher
|
|
4
5
|
import androidx.health.connect.client.PermissionController
|
|
5
|
-
import com.facebook.react.ReactActivity
|
|
6
6
|
import kotlinx.coroutines.CoroutineScope
|
|
7
7
|
import kotlinx.coroutines.Dispatchers
|
|
8
8
|
import kotlinx.coroutines.cancel
|
|
@@ -15,7 +15,7 @@ object HealthConnectPermissionDelegate {
|
|
|
15
15
|
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
|
16
16
|
|
|
17
17
|
fun setPermissionDelegate(
|
|
18
|
-
activity:
|
|
18
|
+
activity: ComponentActivity,
|
|
19
19
|
providerPackageName: String = "com.google.android.apps.healthdata"
|
|
20
20
|
) {
|
|
21
21
|
val contract = PermissionController.createRequestPermissionResultContract(providerPackageName)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-health-connect",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "React native library for health connect (Android only)",
|
|
5
5
|
"funding": "https://github.com/matinzd/react-native-health-connect?sponsor=1",
|
|
6
6
|
"main": "lib/commonjs/index",
|