Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/health/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 12.2.0

* iOS: Add `deviceModel` in returned Health data to identify the device that generated the data of the receiver. (in iOS `source_name` represents the revision of the source responsible for saving the receiver.)

## 12.1.0

* Add delete record by UUID method. See function `deleteByUUID(required String uuid, HealthDataType? type)`
Expand Down
1 change: 1 addition & 0 deletions packages/health/ios/Classes/SwiftHealthPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
"date_to": Int(sample.endDate.timeIntervalSince1970 * 1000),
"source_id": sample.sourceRevision.source.bundleIdentifier,
"source_name": sample.sourceRevision.source.name,
"device_model": sample.device?.model ?? "unknown",
"recording_method": (sample.metadata?[HKMetadataKeyWasUserEntered] as? Bool == true)
? RecordingMethod.manual.rawValue
: RecordingMethod.automatic.rawValue,
Expand Down
2 changes: 1 addition & 1 deletion packages/health/ios/health.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'health'
s.version = '12.1.0'
s.version = '12.2.0'
s.summary = 'Wrapper for Apple\'s HealthKit on iOS and Google\'s Health Connect on Android.'
s.description = <<-DESC
Wrapper for Apple's HealthKit on iOS and Google's Health Connect on Android.
Expand Down
2 changes: 2 additions & 0 deletions packages/health/lib/health.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions packages/health/lib/src/health_data_point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class HealthDataPoint {
/// The metadata for this data point.
Map<String, dynamic>? metadata;

/// The source of the data, whether from the iPhone or Watch or something else.
/// Only available fo iOS
/// On Android: always return null
String? deviceModel;

HealthDataPoint({
required this.uuid,
required this.value,
Expand All @@ -69,6 +74,7 @@ class HealthDataPoint {
this.recordingMethod = RecordingMethod.unknown,
this.workoutSummary,
this.metadata,
this.deviceModel,
}) {
// set the value to minutes rather than the category
// returned by the native API
Expand Down Expand Up @@ -137,6 +143,7 @@ class HealthDataPoint {
: Map<String, dynamic>.from(dataPoint['metadata'] as Map);
final unit = dataTypeToUnit[dataType] ?? HealthDataUnit.UNKNOWN_UNIT;
final String? uuid = dataPoint["uuid"] as String?;
final String? deviceModel = dataPoint["device_model"] as String?;

// Set WorkoutSummary, if available.
WorkoutSummary? workoutSummary;
Expand All @@ -163,6 +170,7 @@ class HealthDataPoint {
recordingMethod: RecordingMethod.fromInt(recordingMethod),
workoutSummary: workoutSummary,
metadata: metadata,
deviceModel: deviceModel,
);
}

Expand All @@ -180,7 +188,8 @@ class HealthDataPoint {
sourceName: $sourceName
recordingMethod: $recordingMethod
workoutSummary: $workoutSummary
metadata: $metadata""";
metadata: $metadata
deviceModel: $deviceModel""";

@override
bool operator ==(Object other) =>
Expand All @@ -196,9 +205,10 @@ class HealthDataPoint {
sourceId == other.sourceId &&
sourceName == other.sourceName &&
recordingMethod == other.recordingMethod &&
metadata == other.metadata;
metadata == other.metadata &&
deviceModel == other.deviceModel;

@override
int get hashCode => Object.hash(uuid, value, unit, dateFrom, dateTo, type,
sourcePlatform, sourceDeviceId, sourceId, sourceName, metadata);
sourcePlatform, sourceDeviceId, sourceId, sourceName, metadata, deviceModel);
}
2 changes: 1 addition & 1 deletion packages/health/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: health
description: Wrapper for Apple's HealthKit on iOS and Google's Health Connect on Android.
version: 12.1.0
version: 12.2.0
homepage: https://github.com/cph-cachet/flutter-plugins/tree/master/packages/health

environment:
Expand Down