@flomentumsolutions/capacitor-health-extended 0.0.16 → 0.0.17

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.
@@ -144,13 +144,19 @@ class HealthPlugin : Plugin() {
144
144
  call.resolve(result)
145
145
  }
146
146
 
147
- // Helper to ensure client is initialized
147
+ // Helper to ensure HealthConnectClient is ready; attempts init lazily
148
148
  private fun ensureClientInitialized(call: PluginCall): Boolean {
149
- if (!available) {
150
- call.reject("Health Connect client not initialized. Call isHealthAvailable() first.")
151
- return false
149
+ if (available) return true
150
+
151
+ return try {
152
+ healthConnectClient = HealthConnectClient.getOrCreate(context)
153
+ available = true
154
+ true
155
+ } catch (e: Exception) {
156
+ Log.e(tag, "Failed to initialise HealthConnectClient", e)
157
+ call.reject("Health Connect is not available on this device.")
158
+ false
152
159
  }
153
- return true
154
160
  }
155
161
 
156
162
  // Check if a set of permissions are granted
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flomentumsolutions/capacitor-health-extended",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "description": "Capacitor plugin for Apple HealthKit and Google Health Connect Platform",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",