@capgo/capacitor-health 7.2.15 → 8.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/CapgoCapacitorHealth.podspec +1 -1
- package/Package.swift +2 -2
- package/README.md +88 -1
- package/android/build.gradle +5 -5
- package/android/src/main/AndroidManifest.xml +29 -0
- package/android/src/main/java/app/capgo/plugin/health/HealthPlugin.kt +26 -0
- package/android/src/main/java/app/capgo/plugin/health/PermissionsRationaleActivity.kt +57 -0
- package/dist/docs.json +32 -2
- package/dist/esm/definitions.d.ts +28 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +2 -0
- package/dist/esm/web.js +6 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +6 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +6 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/HealthPlugin/HealthPlugin.swift +14 -2
- package/package.json +14 -12
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '15.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
16
|
s.swift_version = '5.1'
|
|
17
17
|
s.frameworks = 'HealthKit'
|
package/Package.swift
CHANGED
|
@@ -3,14 +3,14 @@ import PackageDescription
|
|
|
3
3
|
|
|
4
4
|
let package = Package(
|
|
5
5
|
name: "CapgoCapacitorHealth",
|
|
6
|
-
platforms: [.iOS(.
|
|
6
|
+
platforms: [.iOS(.v15)],
|
|
7
7
|
products: [
|
|
8
8
|
.library(
|
|
9
9
|
name: "CapgoCapacitorHealth",
|
|
10
10
|
targets: ["HealthPlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
|
|
14
14
|
],
|
|
15
15
|
targets: [
|
|
16
16
|
.target(
|
package/README.md
CHANGED
|
@@ -49,13 +49,64 @@ npx cap sync
|
|
|
49
49
|
|
|
50
50
|
This plugin now uses [Health Connect](https://developer.android.com/health-and-fitness/guides/health-connect) instead of Google Fit. Make sure your app meets the requirements below:
|
|
51
51
|
|
|
52
|
-
1. **Min SDK 26+.** Health Connect is only available on Android 8.0 (API 26) and above. The plugin
|
|
52
|
+
1. **Min SDK 26+.** Health Connect is only available on Android 8.0 (API 26) and above. The plugin's Gradle setup already targets this level.
|
|
53
53
|
2. **Declare Health permissions.** The plugin manifest ships with the required `<uses-permission>` declarations (`READ_/WRITE_STEPS`, `READ_/WRITE_DISTANCE`, `READ_/WRITE_ACTIVE_CALORIES_BURNED`, `READ_/WRITE_HEART_RATE`, `READ_/WRITE_WEIGHT`). Your app does not need to duplicate them, but you must surface a user-facing rationale because the permissions are considered health sensitive.
|
|
54
54
|
3. **Ensure Health Connect is installed.** Devices on Android 14+ include it by default. For earlier versions the user must install *Health Connect by Android* from the Play Store. The `Health.isAvailable()` helper exposes the current status so you can prompt accordingly.
|
|
55
55
|
4. **Request runtime access.** The plugin opens the Health Connect permission UI when you call `requestAuthorization`. You should still handle denial flows (e.g., show a message if `checkAuthorization` reports missing scopes).
|
|
56
|
+
5. **Provide a Privacy Policy.** Health Connect requires apps to display a privacy policy explaining how health data is used. See the [Privacy Policy Setup](#privacy-policy-setup) section below.
|
|
56
57
|
|
|
57
58
|
If you already used Google Fit in your project you can remove the associated dependencies (`play-services-fitness`, `play-services-auth`, OAuth configuration, etc.).
|
|
58
59
|
|
|
60
|
+
### Privacy Policy Setup
|
|
61
|
+
|
|
62
|
+
Health Connect requires your app to provide a privacy policy that explains how you handle health data. When users tap "Privacy policy" in the Health Connect permissions dialog, your app must display this information.
|
|
63
|
+
|
|
64
|
+
**Option 1: HTML file in assets (recommended for simple cases)**
|
|
65
|
+
|
|
66
|
+
Place an HTML file at `android/app/src/main/assets/public/privacypolicy.html`:
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<!DOCTYPE html>
|
|
70
|
+
<html>
|
|
71
|
+
<head>
|
|
72
|
+
<meta charset="utf-8">
|
|
73
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
74
|
+
<title>Privacy Policy</title>
|
|
75
|
+
</head>
|
|
76
|
+
<body>
|
|
77
|
+
<h1>Privacy Policy</h1>
|
|
78
|
+
<p>Your privacy policy content here...</p>
|
|
79
|
+
<h2>Health Data</h2>
|
|
80
|
+
<p>Explain how you collect, use, and protect health data...</p>
|
|
81
|
+
</body>
|
|
82
|
+
</html>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Option 2: Custom URL (recommended for hosted privacy policies)**
|
|
86
|
+
|
|
87
|
+
Add a string resource to your app's `android/app/src/main/res/values/strings.xml`:
|
|
88
|
+
|
|
89
|
+
```xml
|
|
90
|
+
<resources>
|
|
91
|
+
<!-- Your other strings... -->
|
|
92
|
+
<string name="health_connect_privacy_policy_url">https://yourapp.com/privacy-policy</string>
|
|
93
|
+
</resources>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This URL will be loaded in a WebView when the user requests to see your privacy policy.
|
|
97
|
+
|
|
98
|
+
**Programmatic access:**
|
|
99
|
+
|
|
100
|
+
You can also show the privacy policy or open Health Connect settings from your app:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
// Show the privacy policy screen
|
|
104
|
+
await Health.showPrivacyPolicy();
|
|
105
|
+
|
|
106
|
+
// Open Health Connect settings (useful for managing permissions)
|
|
107
|
+
await Health.openHealthConnectSettings();
|
|
108
|
+
```
|
|
109
|
+
|
|
59
110
|
## Usage
|
|
60
111
|
|
|
61
112
|
```ts
|
|
@@ -110,6 +161,8 @@ All write operations expect the default unit shown above. On Android the `metada
|
|
|
110
161
|
* [`readSamples(...)`](#readsamples)
|
|
111
162
|
* [`saveSample(...)`](#savesample)
|
|
112
163
|
* [`getPluginVersion()`](#getpluginversion)
|
|
164
|
+
* [`openHealthConnectSettings()`](#openhealthconnectsettings)
|
|
165
|
+
* [`showPrivacyPolicy()`](#showprivacypolicy)
|
|
113
166
|
* [Interfaces](#interfaces)
|
|
114
167
|
* [Type Aliases](#type-aliases)
|
|
115
168
|
|
|
@@ -210,6 +263,40 @@ Get the native Capacitor plugin version
|
|
|
210
263
|
--------------------
|
|
211
264
|
|
|
212
265
|
|
|
266
|
+
### openHealthConnectSettings()
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
openHealthConnectSettings() => Promise<void>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Opens the Health Connect settings screen (Android only).
|
|
273
|
+
On iOS, this method does nothing.
|
|
274
|
+
|
|
275
|
+
Use this to direct users to manage their Health Connect permissions
|
|
276
|
+
or to install Health Connect if not available.
|
|
277
|
+
|
|
278
|
+
--------------------
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
### showPrivacyPolicy()
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
showPrivacyPolicy() => Promise<void>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Shows the app's privacy policy for Health Connect (Android only).
|
|
288
|
+
On iOS, this method does nothing.
|
|
289
|
+
|
|
290
|
+
This displays the same privacy policy screen that Health Connect shows
|
|
291
|
+
when the user taps "Privacy policy" in the permissions dialog.
|
|
292
|
+
|
|
293
|
+
The privacy policy URL can be configured by adding a string resource
|
|
294
|
+
named "health_connect_privacy_policy_url" in your app's strings.xml,
|
|
295
|
+
or by placing an HTML file at www/privacypolicy.html in your assets.
|
|
296
|
+
|
|
297
|
+
--------------------
|
|
298
|
+
|
|
299
|
+
|
|
213
300
|
### Interfaces
|
|
214
301
|
|
|
215
302
|
|
package/android/build.gradle
CHANGED
|
@@ -14,7 +14,7 @@ buildscript {
|
|
|
14
14
|
mavenCentral()
|
|
15
15
|
}
|
|
16
16
|
dependencies {
|
|
17
|
-
classpath 'com.android.tools.build:gradle:8.
|
|
17
|
+
classpath 'com.android.tools.build:gradle:8.13.0'
|
|
18
18
|
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24'
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -23,12 +23,12 @@ apply plugin: 'com.android.library'
|
|
|
23
23
|
apply plugin: 'org.jetbrains.kotlin.android'
|
|
24
24
|
|
|
25
25
|
android {
|
|
26
|
-
namespace "app.capgo.plugin.health"
|
|
27
|
-
compileSdk
|
|
26
|
+
namespace = "app.capgo.plugin.health"
|
|
27
|
+
compileSdk = 36
|
|
28
28
|
|
|
29
29
|
defaultConfig {
|
|
30
30
|
minSdk 26
|
|
31
|
-
targetSdk
|
|
31
|
+
targetSdk 36
|
|
32
32
|
versionCode 1
|
|
33
33
|
versionName "1.0"
|
|
34
34
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -40,7 +40,7 @@ android {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
lint {
|
|
43
|
-
abortOnError false
|
|
43
|
+
abortOnError = false
|
|
44
44
|
}
|
|
45
45
|
compileOptions {
|
|
46
46
|
sourceCompatibility JavaVersion.VERSION_21
|
|
@@ -9,4 +9,33 @@
|
|
|
9
9
|
<uses-permission android:name="android.permission.health.WRITE_HEART_RATE" />
|
|
10
10
|
<uses-permission android:name="android.permission.health.READ_WEIGHT" />
|
|
11
11
|
<uses-permission android:name="android.permission.health.WRITE_WEIGHT" />
|
|
12
|
+
|
|
13
|
+
<!-- Query for Health Connect availability -->
|
|
14
|
+
<queries>
|
|
15
|
+
<package android:name="com.google.android.apps.healthdata" />
|
|
16
|
+
</queries>
|
|
17
|
+
|
|
18
|
+
<application>
|
|
19
|
+
<!-- Activity to display privacy policy rationale for Health Connect permissions (Android 13 and earlier) -->
|
|
20
|
+
<activity
|
|
21
|
+
android:name=".PermissionsRationaleActivity"
|
|
22
|
+
android:exported="true"
|
|
23
|
+
android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
|
24
|
+
<intent-filter>
|
|
25
|
+
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
|
|
26
|
+
</intent-filter>
|
|
27
|
+
</activity>
|
|
28
|
+
|
|
29
|
+
<!-- Activity alias for Android 14+ (API 34+) permission usage view -->
|
|
30
|
+
<activity-alias
|
|
31
|
+
android:name=".ViewPermissionUsageActivity"
|
|
32
|
+
android:exported="true"
|
|
33
|
+
android:targetActivity=".PermissionsRationaleActivity"
|
|
34
|
+
android:permission="android.permission.START_VIEW_PERMISSION_USAGE">
|
|
35
|
+
<intent-filter>
|
|
36
|
+
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE" />
|
|
37
|
+
<category android:name="android.intent.category.HEALTH_PERMISSIONS" />
|
|
38
|
+
</intent-filter>
|
|
39
|
+
</activity-alias>
|
|
40
|
+
</application>
|
|
12
41
|
</manifest>
|
|
@@ -2,6 +2,7 @@ package app.capgo.plugin.health
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Intent
|
|
5
|
+
import android.net.Uri
|
|
5
6
|
import androidx.activity.result.ActivityResult
|
|
6
7
|
import com.getcapacitor.JSArray
|
|
7
8
|
import com.getcapacitor.JSObject
|
|
@@ -302,8 +303,33 @@ class HealthPlugin : Plugin() {
|
|
|
302
303
|
}
|
|
303
304
|
}
|
|
304
305
|
|
|
306
|
+
@PluginMethod
|
|
307
|
+
fun openHealthConnectSettings(call: PluginCall) {
|
|
308
|
+
try {
|
|
309
|
+
val intent = Intent(HEALTH_CONNECT_SETTINGS_ACTION)
|
|
310
|
+
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
311
|
+
context.startActivity(intent)
|
|
312
|
+
call.resolve()
|
|
313
|
+
} catch (e: Exception) {
|
|
314
|
+
call.reject("Failed to open Health Connect settings", null, e)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
@PluginMethod
|
|
319
|
+
fun showPrivacyPolicy(call: PluginCall) {
|
|
320
|
+
try {
|
|
321
|
+
val intent = Intent(context, PermissionsRationaleActivity::class.java)
|
|
322
|
+
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
|
323
|
+
context.startActivity(intent)
|
|
324
|
+
call.resolve()
|
|
325
|
+
} catch (e: Exception) {
|
|
326
|
+
call.reject("Failed to show privacy policy", null, e)
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
305
330
|
companion object {
|
|
306
331
|
private const val DEFAULT_LIMIT = 100
|
|
307
332
|
private val DEFAULT_PAST_DURATION: Duration = Duration.ofDays(1)
|
|
333
|
+
private const val HEALTH_CONNECT_SETTINGS_ACTION = "androidx.health.ACTION_HEALTH_CONNECT_SETTINGS"
|
|
308
334
|
}
|
|
309
335
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
package app.capgo.plugin.health
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import android.webkit.WebView
|
|
6
|
+
import android.webkit.WebViewClient
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Activity that displays the app's privacy policy for Health Connect permissions.
|
|
10
|
+
*
|
|
11
|
+
* This activity is launched by Health Connect when the user wants to see why the app
|
|
12
|
+
* needs health data access. It displays a WebView with the privacy policy.
|
|
13
|
+
*
|
|
14
|
+
* The privacy policy URL can be customized by defining a string resource named
|
|
15
|
+
* "health_connect_privacy_policy_url" in your app's res/values/strings.xml:
|
|
16
|
+
*
|
|
17
|
+
* ```xml
|
|
18
|
+
* <resources>
|
|
19
|
+
* <string name="health_connect_privacy_policy_url">https://yourapp.com/privacy</string>
|
|
20
|
+
* </resources>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Alternatively, you can place an HTML file at www/privacypolicy.html in your assets.
|
|
24
|
+
*/
|
|
25
|
+
class PermissionsRationaleActivity : Activity() {
|
|
26
|
+
|
|
27
|
+
private val defaultUrl = "file:///android_asset/public/privacypolicy.html"
|
|
28
|
+
|
|
29
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
30
|
+
super.onCreate(savedInstanceState)
|
|
31
|
+
|
|
32
|
+
val webView = WebView(applicationContext)
|
|
33
|
+
webView.webViewClient = WebViewClient()
|
|
34
|
+
webView.settings.javaScriptEnabled = false
|
|
35
|
+
setContentView(webView)
|
|
36
|
+
|
|
37
|
+
val url = getPrivacyPolicyUrl()
|
|
38
|
+
webView.loadUrl(url)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private fun getPrivacyPolicyUrl(): String {
|
|
42
|
+
return try {
|
|
43
|
+
val resId = resources.getIdentifier(
|
|
44
|
+
"health_connect_privacy_policy_url",
|
|
45
|
+
"string",
|
|
46
|
+
packageName
|
|
47
|
+
)
|
|
48
|
+
if (resId != 0) {
|
|
49
|
+
getString(resId)
|
|
50
|
+
} else {
|
|
51
|
+
defaultUrl
|
|
52
|
+
}
|
|
53
|
+
} catch (e: Exception) {
|
|
54
|
+
defaultUrl
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/docs.json
CHANGED
|
@@ -100,16 +100,46 @@
|
|
|
100
100
|
"tags": [
|
|
101
101
|
{
|
|
102
102
|
"name": "returns",
|
|
103
|
-
"text": "
|
|
103
|
+
"text": "a Promise with version for this device"
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"name": "throws",
|
|
107
|
-
"text": "An error if
|
|
107
|
+
"text": "An error if something went wrong"
|
|
108
108
|
}
|
|
109
109
|
],
|
|
110
110
|
"docs": "Get the native Capacitor plugin version",
|
|
111
111
|
"complexTypes": [],
|
|
112
112
|
"slug": "getpluginversion"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "openHealthConnectSettings",
|
|
116
|
+
"signature": "() => Promise<void>",
|
|
117
|
+
"parameters": [],
|
|
118
|
+
"returns": "Promise<void>",
|
|
119
|
+
"tags": [
|
|
120
|
+
{
|
|
121
|
+
"name": "throws",
|
|
122
|
+
"text": "An error if Health Connect settings cannot be opened"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"docs": "Opens the Health Connect settings screen (Android only).\nOn iOS, this method does nothing.\n\nUse this to direct users to manage their Health Connect permissions\nor to install Health Connect if not available.",
|
|
126
|
+
"complexTypes": [],
|
|
127
|
+
"slug": "openhealthconnectsettings"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "showPrivacyPolicy",
|
|
131
|
+
"signature": "() => Promise<void>",
|
|
132
|
+
"parameters": [],
|
|
133
|
+
"returns": "Promise<void>",
|
|
134
|
+
"tags": [
|
|
135
|
+
{
|
|
136
|
+
"name": "throws",
|
|
137
|
+
"text": "An error if the privacy policy cannot be displayed"
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
"docs": "Shows the app's privacy policy for Health Connect (Android only).\nOn iOS, this method does nothing.\n\nThis displays the same privacy policy screen that Health Connect shows\nwhen the user taps \"Privacy policy\" in the permissions dialog.\n\nThe privacy policy URL can be configured by adding a string resource\nnamed \"health_connect_privacy_policy_url\" in your app's strings.xml,\nor by placing an HTML file at www/privacypolicy.html in your assets.",
|
|
141
|
+
"complexTypes": [],
|
|
142
|
+
"slug": "showprivacypolicy"
|
|
113
143
|
}
|
|
114
144
|
],
|
|
115
145
|
"properties": []
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight';
|
|
2
|
+
export type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';
|
|
3
3
|
export interface AuthorizationOptions {
|
|
4
4
|
/** Data types that should be readable after authorization. */
|
|
5
5
|
read?: HealthDataType[];
|
|
@@ -71,10 +71,34 @@ export interface HealthPlugin {
|
|
|
71
71
|
/**
|
|
72
72
|
* Get the native Capacitor plugin version
|
|
73
73
|
*
|
|
74
|
-
* @returns {Promise<{
|
|
75
|
-
* @throws An error if
|
|
74
|
+
* @returns {Promise<{ version: string }>} a Promise with version for this device
|
|
75
|
+
* @throws An error if something went wrong
|
|
76
76
|
*/
|
|
77
77
|
getPluginVersion(): Promise<{
|
|
78
78
|
version: string;
|
|
79
79
|
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Opens the Health Connect settings screen (Android only).
|
|
82
|
+
* On iOS, this method does nothing.
|
|
83
|
+
*
|
|
84
|
+
* Use this to direct users to manage their Health Connect permissions
|
|
85
|
+
* or to install Health Connect if not available.
|
|
86
|
+
*
|
|
87
|
+
* @throws An error if Health Connect settings cannot be opened
|
|
88
|
+
*/
|
|
89
|
+
openHealthConnectSettings(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Shows the app's privacy policy for Health Connect (Android only).
|
|
92
|
+
* On iOS, this method does nothing.
|
|
93
|
+
*
|
|
94
|
+
* This displays the same privacy policy screen that Health Connect shows
|
|
95
|
+
* when the user taps "Privacy policy" in the permissions dialog.
|
|
96
|
+
*
|
|
97
|
+
* The privacy policy URL can be configured by adding a string resource
|
|
98
|
+
* named "health_connect_privacy_policy_url" in your app's strings.xml,
|
|
99
|
+
* or by placing an HTML file at www/privacypolicy.html in your assets.
|
|
100
|
+
*
|
|
101
|
+
* @throws An error if the privacy policy cannot be displayed
|
|
102
|
+
*/
|
|
103
|
+
showPrivacyPolicy(): Promise<void>;
|
|
80
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';\n\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'ios' | 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`).\n */\n unit?: HealthUnit;\n /** ISO 8601 start date for the sample. Defaults to now. */\n startDate?: string;\n /** ISO 8601 end date for the sample. Defaults to startDate. */\n endDate?: string;\n /** Metadata key-value pairs forwarded to the native APIs where supported. */\n metadata?: Record<string, string>;\n}\n\nexport interface HealthPlugin {\n /** Returns whether the current platform supports the native health SDK. */\n isAvailable(): Promise<AvailabilityResult>;\n /** Requests read/write access to the provided data types. */\n requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Checks authorization status for the provided data types without prompting the user. */\n checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Reads samples for the given data type within the specified time frame. */\n readSamples(options: QueryOptions): Promise<ReadSamplesResult>;\n /** Writes a single sample to the native health store. */\n saveSample(options: WriteSampleOptions): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';\n\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'ios' | 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`).\n */\n unit?: HealthUnit;\n /** ISO 8601 start date for the sample. Defaults to now. */\n startDate?: string;\n /** ISO 8601 end date for the sample. Defaults to startDate. */\n endDate?: string;\n /** Metadata key-value pairs forwarded to the native APIs where supported. */\n metadata?: Record<string, string>;\n}\n\nexport interface HealthPlugin {\n /** Returns whether the current platform supports the native health SDK. */\n isAvailable(): Promise<AvailabilityResult>;\n /** Requests read/write access to the provided data types. */\n requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Checks authorization status for the provided data types without prompting the user. */\n checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Reads samples for the given data type within the specified time frame. */\n readSamples(options: QueryOptions): Promise<ReadSamplesResult>;\n /** Writes a single sample to the native health store. */\n saveSample(options: WriteSampleOptions): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ version: string }>} a Promise with version for this device\n * @throws An error if something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Opens the Health Connect settings screen (Android only).\n * On iOS, this method does nothing.\n *\n * Use this to direct users to manage their Health Connect permissions\n * or to install Health Connect if not available.\n *\n * @throws An error if Health Connect settings cannot be opened\n */\n openHealthConnectSettings(): Promise<void>;\n\n /**\n * Shows the app's privacy policy for Health Connect (Android only).\n * On iOS, this method does nothing.\n *\n * This displays the same privacy policy screen that Health Connect shows\n * when the user taps \"Privacy policy\" in the permissions dialog.\n *\n * The privacy policy URL can be configured by adding a string resource\n * named \"health_connect_privacy_policy_url\" in your app's strings.xml,\n * or by placing an HTML file at www/privacypolicy.html in your assets.\n *\n * @throws An error if the privacy policy cannot be displayed\n */\n showPrivacyPolicy(): Promise<void>;\n}\n"]}
|
package/dist/esm/web.d.ts
CHANGED
package/dist/esm/web.js
CHANGED
|
@@ -22,5 +22,11 @@ export class HealthWeb extends WebPlugin {
|
|
|
22
22
|
async getPluginVersion() {
|
|
23
23
|
return { version: 'web' };
|
|
24
24
|
}
|
|
25
|
+
async openHealthConnectSettings() {
|
|
26
|
+
// No-op on web - Health Connect is Android only
|
|
27
|
+
}
|
|
28
|
+
async showPrivacyPolicy() {
|
|
29
|
+
// No-op on web - Health Connect privacy policy is Android only
|
|
30
|
+
}
|
|
25
31
|
}
|
|
26
32
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,KAAK,CAAC,WAAW;QACf,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,iEAAiE;SAC1E,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAA8B;QACvD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA8B;QACrD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAsB;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA4B;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationOptions,\n AuthorizationStatus,\n AvailabilityResult,\n HealthPlugin,\n QueryOptions,\n ReadSamplesResult,\n WriteSampleOptions,\n} from './definitions';\n\nexport class HealthWeb extends WebPlugin implements HealthPlugin {\n async isAvailable(): Promise<AvailabilityResult> {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n\n async requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async readSamples(_options: QueryOptions): Promise<ReadSamplesResult> {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n\n async saveSample(_options: WriteSampleOptions): Promise<void> {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,KAAK,CAAC,WAAW;QACf,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,iEAAiE;SAC1E,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAA8B;QACvD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA8B;QACrD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAsB;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA4B;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,yBAAyB;QAC7B,gDAAgD;IAClD,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,+DAA+D;IACjE,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationOptions,\n AuthorizationStatus,\n AvailabilityResult,\n HealthPlugin,\n QueryOptions,\n ReadSamplesResult,\n WriteSampleOptions,\n} from './definitions';\n\nexport class HealthWeb extends WebPlugin implements HealthPlugin {\n async isAvailable(): Promise<AvailabilityResult> {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n\n async requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async readSamples(_options: QueryOptions): Promise<ReadSamplesResult> {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n\n async saveSample(_options: WriteSampleOptions): Promise<void> {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async openHealthConnectSettings(): Promise<void> {\n // No-op on web - Health Connect is Android only\n }\n\n async showPrivacyPolicy(): Promise<void> {\n // No-op on web - Health Connect privacy policy is Android only\n }\n}\n"]}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -29,6 +29,12 @@ class HealthWeb extends core.WebPlugin {
|
|
|
29
29
|
async getPluginVersion() {
|
|
30
30
|
return { version: 'web' };
|
|
31
31
|
}
|
|
32
|
+
async openHealthConnectSettings() {
|
|
33
|
+
// No-op on web - Health Connect is Android only
|
|
34
|
+
}
|
|
35
|
+
async showPrivacyPolicy() {
|
|
36
|
+
// No-op on web - Health Connect privacy policy is Android only
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,KAAK;AAC5B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,MAAM,EAAE,iEAAiE;AACrF,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;AACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,KAAK;AAC5B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,MAAM,EAAE,iEAAiE;AACrF,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;AACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,yBAAyB,GAAG;AACtC;AACA,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B;AACA,IAAI;AACJ;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -28,6 +28,12 @@ var capacitorHealth = (function (exports, core) {
|
|
|
28
28
|
async getPluginVersion() {
|
|
29
29
|
return { version: 'web' };
|
|
30
30
|
}
|
|
31
|
+
async openHealthConnectSettings() {
|
|
32
|
+
// No-op on web - Health Connect is Android only
|
|
33
|
+
}
|
|
34
|
+
async showPrivacyPolicy() {
|
|
35
|
+
// No-op on web - Health Connect privacy policy is Android only
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
var web = /*#__PURE__*/Object.freeze({
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO;IACf,YAAY,SAAS,EAAE,KAAK;IAC5B,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,MAAM,EAAE,iEAAiE;IACrF,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;IACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO;IACf,YAAY,SAAS,EAAE,KAAK;IAC5B,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,MAAM,EAAE,iEAAiE;IACrF,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;IACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,yBAAyB,GAAG;IACtC;IACA,IAAI;IACJ,IAAI,MAAM,iBAAiB,GAAG;IAC9B;IACA,IAAI;IACJ;;;;;;;;;;;;;;;"}
|
|
@@ -3,7 +3,7 @@ import Capacitor
|
|
|
3
3
|
|
|
4
4
|
@objc(HealthPlugin)
|
|
5
5
|
public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
-
private let pluginVersion: String = "
|
|
6
|
+
private let pluginVersion: String = "8.1.0"
|
|
7
7
|
public let identifier = "HealthPlugin"
|
|
8
8
|
public let jsName = "Health"
|
|
9
9
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -12,7 +12,9 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
12
12
|
CAPPluginMethod(name: "checkAuthorization", returnType: CAPPluginReturnPromise),
|
|
13
13
|
CAPPluginMethod(name: "readSamples", returnType: CAPPluginReturnPromise),
|
|
14
14
|
CAPPluginMethod(name: "saveSample", returnType: CAPPluginReturnPromise),
|
|
15
|
-
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
|
|
15
|
+
CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise),
|
|
16
|
+
CAPPluginMethod(name: "openHealthConnectSettings", returnType: CAPPluginReturnPromise),
|
|
17
|
+
CAPPluginMethod(name: "showPrivacyPolicy", returnType: CAPPluginReturnPromise)
|
|
16
18
|
]
|
|
17
19
|
|
|
18
20
|
private let implementation = Health()
|
|
@@ -134,4 +136,14 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
134
136
|
call.resolve(["version": self.pluginVersion])
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
@objc func openHealthConnectSettings(_ call: CAPPluginCall) {
|
|
140
|
+
// No-op on iOS - Health Connect is Android only
|
|
141
|
+
call.resolve()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@objc func showPrivacyPolicy(_ call: CAPPluginCall) {
|
|
145
|
+
// No-op on iOS - Health Connect privacy policy is Android only
|
|
146
|
+
call.resolve()
|
|
147
|
+
}
|
|
148
|
+
|
|
137
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-health",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Capacitor plugin to interact with data from Apple HealthKit and Health Connect",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -46,23 +46,25 @@
|
|
|
46
46
|
"prepublishOnly": "npm run build"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@capacitor/android": "^
|
|
50
|
-
"@capacitor/core": "^
|
|
51
|
-
"@capacitor/docgen": "^0.3.
|
|
52
|
-
"@capacitor/ios": "^
|
|
49
|
+
"@capacitor/android": "^8.0.0",
|
|
50
|
+
"@capacitor/core": "^8.0.0",
|
|
51
|
+
"@capacitor/docgen": "^0.3.1",
|
|
52
|
+
"@capacitor/ios": "^8.0.0",
|
|
53
53
|
"@ionic/eslint-config": "^0.4.0",
|
|
54
54
|
"@ionic/prettier-config": "^4.0.0",
|
|
55
55
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
56
|
+
"@types/node": "^24.10.1",
|
|
57
|
+
"eslint": "^8.57.1",
|
|
58
|
+
"eslint-plugin-import": "^2.31.0",
|
|
59
|
+
"prettier": "^3.6.2",
|
|
60
|
+
"prettier-plugin-java": "^2.7.7",
|
|
61
|
+
"rimraf": "^6.1.0",
|
|
62
|
+
"rollup": "^4.53.2",
|
|
61
63
|
"swiftlint": "^2.0.0",
|
|
62
|
-
"typescript": "
|
|
64
|
+
"typescript": "^5.9.3"
|
|
63
65
|
},
|
|
64
66
|
"peerDependencies": {
|
|
65
|
-
"@capacitor/core": ">=
|
|
67
|
+
"@capacitor/core": ">=8.0.0"
|
|
66
68
|
},
|
|
67
69
|
"prettier": "@ionic/prettier-config",
|
|
68
70
|
"swiftlint": "@ionic/swiftlint-config",
|