@flomentumsolutions/capacitor-health-extended 0.0.13 → 0.0.14

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.
@@ -253,9 +253,36 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
253
253
  }
254
254
 
255
255
  private func queryLatestSampleWithType(_ call: CAPPluginCall, dataType: String) {
256
- let params = NSMutableDictionary(dictionary: call.options ?? [:])
256
+ // Safely coerce the original options into a [String: Any] JSObject.
257
+ let originalOptions = call.options as? [String: Any] ?? [:]
258
+ var params = originalOptions
257
259
  params["dataType"] = dataType
258
- let proxyCall = CAPPluginCall(callbackId: call.callbackId, options: params as? [String: Any], success: call.success, error: call.error)
260
+
261
+ // Create a proxy CAPPluginCall using the CURRENT (Capacitor 6) designated initializer.
262
+ // NOTE: The older init(callbackId:options:success:error:) is deprecated and *failable*,
263
+ // so we use the newer initializer that requires a method name. Guard against failure.
264
+ guard let proxyCall = CAPPluginCall(
265
+ callbackId: call.callbackId,
266
+ methodName: "queryLatestSample", // required in new API
267
+ options: params,
268
+ success: { result, _ in
269
+ // Forward the resolved data back to the original JS caller.
270
+ call.resolve(result?.data ?? [:])
271
+ },
272
+ error: { capError in
273
+ // Forward the error to the original call in the legacy reject format.
274
+ if let capError = capError {
275
+ call.reject(capError.message, capError.code, capError.error, capError.data)
276
+ } else {
277
+ call.reject("Unknown native error")
278
+ }
279
+ }
280
+ ) else {
281
+ call.reject("Failed to create proxy call")
282
+ return
283
+ }
284
+
285
+ // Delegate the actual HealthKit fetch to the common implementation.
259
286
  queryLatestSample(proxyCall)
260
287
  }
261
288
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flomentumsolutions/capacitor-health-extended",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
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",