@flomentumsolutions/capacitor-health-extended 0.0.13 → 0.0.15
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/android/build.gradle
CHANGED
|
@@ -61,7 +61,7 @@ dependencies {
|
|
|
61
61
|
implementation project(':capacitor-android')
|
|
62
62
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
63
63
|
|
|
64
|
-
implementation 'androidx.health.connect:connect-client:1.1.0-
|
|
64
|
+
implementation 'androidx.health.connect:connect-client:1.1.0-rc03'
|
|
65
65
|
implementation 'androidx.core:core-ktx:1.13.1'
|
|
66
66
|
|
|
67
67
|
testImplementation "junit:junit:$junitVersion"
|
|
@@ -253,9 +253,36 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
private func queryLatestSampleWithType(_ call: CAPPluginCall, dataType: String) {
|
|
256
|
-
|
|
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
|
-
|
|
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