@flomentumsolutions/capacitor-health-extended 0.0.10 → 0.0.11
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.
|
@@ -65,8 +65,19 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
65
65
|
return
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
print("⚡️ [HealthPlugin] Requesting permissions: \(permissions)")
|
|
69
|
+
|
|
68
70
|
let types: [HKObjectType] = permissions.flatMap { permissionToHKObjectType($0) }
|
|
69
71
|
|
|
72
|
+
print("⚡️ [HealthPlugin] Mapped to \(types.count) HKObjectTypes")
|
|
73
|
+
|
|
74
|
+
// Validate that we have at least one valid permission type
|
|
75
|
+
guard !types.isEmpty else {
|
|
76
|
+
let invalidPermissions = permissions.filter { permissionToHKObjectType($0).isEmpty }
|
|
77
|
+
call.reject("No valid permission types found. Invalid permissions: \(invalidPermissions)")
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
70
81
|
healthStore.requestAuthorization(toShare: nil, read: Set(types)) { success, error in
|
|
71
82
|
if success {
|
|
72
83
|
//we don't know which actual permissions were granted, so we assume all
|
|
@@ -263,7 +274,44 @@ public class HealthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
263
274
|
HKObjectType.quantityType(forIdentifier: .bloodPressureSystolic),
|
|
264
275
|
HKObjectType.quantityType(forIdentifier: .bloodPressureDiastolic)
|
|
265
276
|
].compactMap { $0 }
|
|
277
|
+
// Add common alternative permission names
|
|
278
|
+
case "steps":
|
|
279
|
+
return [HKObjectType.quantityType(forIdentifier: .stepCount)].compactMap{$0}
|
|
280
|
+
case "weight":
|
|
281
|
+
return [HKObjectType.quantityType(forIdentifier: .bodyMass)].compactMap{$0}
|
|
282
|
+
case "height":
|
|
283
|
+
return [HKObjectType.quantityType(forIdentifier: .height)].compactMap { $0 }
|
|
284
|
+
case "calories", "total-calories":
|
|
285
|
+
return [
|
|
286
|
+
HKObjectType.quantityType(forIdentifier: .activeEnergyBurned),
|
|
287
|
+
HKObjectType.quantityType(forIdentifier: .basalEnergyBurned) // iOS 16+
|
|
288
|
+
].compactMap { $0 }
|
|
289
|
+
case "active-calories":
|
|
290
|
+
return [HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)].compactMap{$0}
|
|
291
|
+
case "workouts":
|
|
292
|
+
return [HKObjectType.workoutType()].compactMap{$0}
|
|
293
|
+
case "heart-rate", "heartrate":
|
|
294
|
+
return [HKObjectType.quantityType(forIdentifier: .heartRate)].compactMap{$0}
|
|
295
|
+
case "route":
|
|
296
|
+
return [HKSeriesType.workoutRoute()].compactMap{$0}
|
|
297
|
+
case "distance":
|
|
298
|
+
return [
|
|
299
|
+
HKObjectType.quantityType(forIdentifier: .distanceCycling),
|
|
300
|
+
HKObjectType.quantityType(forIdentifier: .distanceSwimming),
|
|
301
|
+
HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning),
|
|
302
|
+
HKObjectType.quantityType(forIdentifier: .distanceDownhillSnowSports)
|
|
303
|
+
].compactMap{$0}
|
|
304
|
+
case "mindfulness":
|
|
305
|
+
return [HKObjectType.categoryType(forIdentifier: .mindfulSession)!].compactMap{$0}
|
|
306
|
+
case "hrv":
|
|
307
|
+
return [HKObjectType.quantityType(forIdentifier: .heartRateVariabilitySDNN)].compactMap { $0 }
|
|
308
|
+
case "blood-pressure", "bloodpressure":
|
|
309
|
+
return [
|
|
310
|
+
HKObjectType.quantityType(forIdentifier: .bloodPressureSystolic),
|
|
311
|
+
HKObjectType.quantityType(forIdentifier: .bloodPressureDiastolic)
|
|
312
|
+
].compactMap { $0 }
|
|
266
313
|
default:
|
|
314
|
+
print("⚡️ [HealthPlugin] Unknown permission: \(permission)")
|
|
267
315
|
return []
|
|
268
316
|
}
|
|
269
317
|
}
|
package/package.json
CHANGED