Skip to content

Commit

Permalink
version 2.0.3
Browse files Browse the repository at this point in the history
- ecg measurements with voltage measurements on demand, because the amount might be very significant like 15000+ values
  • Loading branch information
victor kachalov committed Apr 18, 2022
1 parent 9190ad5 commit 7e7b6a4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.0.3] - 18.04.2022

* ECG with Voltage measurements in one query on demand

## [2.0.2] - 18.04.2022

* ECG with Voltage measurements in one query
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PODS:
- health_kit_reporter (1.5.2):
- Flutter
- HealthKitReporter
- HealthKitReporter (1.6.4)
- HealthKitReporter (1.6.5)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -28,7 +28,7 @@ SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
health_kit_reporter: 6da8c20414d6a53cf2babcfd0314ea05a943bd3e
HealthKitReporter: 313a822918d705beb27bdeeb5794c1afa4fe88bb
HealthKitReporter: cec816c8f9477c8a0a8e2f90dd7aa0780bf21e16

PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa

Expand Down
5 changes: 3 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ class _ReadView extends StatelessWidget with HealthKitReporterMixin {

void queryElectrocardiograms() async {
try {
final electrocardiograms =
await HealthKitReporter.electrocardiogramQuery(predicate);
final electrocardiograms = await HealthKitReporter.electrocardiogramQuery(
predicate,
withVoltageMeasurements: true);
print(
'electrocardiograms: ${electrocardiograms.map((e) => e.map).toList()}');
} catch (e) {
Expand Down
12 changes: 7 additions & 5 deletions ios/Classes/Extensions+SwiftHealthKitReporterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension SwiftHealthKitReporterPlugin {
result: result
)
case .electrocardiogramQuery:
guard let arguments = call.arguments as? [String: Double] else {
guard let arguments = call.arguments as? [String: Any] else {
throwNoArgumentsError(result: result)
return
}
Expand Down Expand Up @@ -532,12 +532,13 @@ extension SwiftHealthKitReporterPlugin {
}
private func electrocardiogramQuery(
reporter: HealthKitReporter,
arguments: [String: Double],
arguments: [String: Any],
result: @escaping FlutterResult
) {
guard
let startTimestamp = arguments["startTimestamp"],
let endTimestamp = arguments["endTimestamp"]
let startTimestamp = arguments["startTimestamp"] as? Double,
let endTimestamp = arguments["endTimestamp"] as? Double,
let withVoltageMeasurements = arguments["withVoltageMeasurements"] as? Bool
else {
throwParsingArgumentsError(result: result, arguments: arguments)
return
Expand All @@ -549,7 +550,8 @@ extension SwiftHealthKitReporterPlugin {
if #available(iOS 14.0, *) {
do {
let query = try reporter.reader.electrocardiogramQuery(
predicate: predicate
predicate: predicate,
withVoltageMeasurements: withVoltageMeasurements
) { (electrocardiograms, error) in
guard error == nil else {
result(
Expand Down
12 changes: 8 additions & 4 deletions lib/health_kit_reporter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,14 @@ class HealthKitReporter {
/// time interval predicate [predicate].
///
static Future<List<Electrocardiogram>> electrocardiogramQuery(
Predicate predicate) async {
final result = await _methodChannel.invokeMethod(
'electrocardiogramQuery', predicate.map);
print(result);
Predicate predicate,
{bool withVoltageMeasurements = false}) async {
final arguments = <String, dynamic>{
'withVoltageMeasurements': withVoltageMeasurements,
};
arguments.addAll(predicate.map);
final result =
await _methodChannel.invokeMethod('electrocardiogramQuery', arguments);
final List<dynamic> list = jsonDecode(result);
final electrocardiograms = <Electrocardiogram>[];
for (final Map<String, dynamic> map in list) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: health_kit_reporter
description: Helps to write or read data from Apple Health via HealthKit framework.
version: 2.0.2
version: 2.0.3
homepage: https://github.com/VictorKachalov/health_kit_reporter

environment:
Expand Down

0 comments on commit 7e7b6a4

Please sign in to comment.