From c4a2d59d0ed1777c34e63d0721c53410161cdc00 Mon Sep 17 00:00:00 2001 From: Evgenii Evstropov Date: Tue, 20 Feb 2018 12:12:50 +0100 Subject: [PATCH] detect if quantity type is mile that write it as a distance field --- RCTAppleHealthKit/RCTAppleHealthKit+Queries.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m b/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m index 42d41e7..45f8720 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Queries.m @@ -165,6 +165,11 @@ HKQuantity *quantity = sample.quantity; double value = [quantity doubleValueForUnit:unit]; + NSString * valueType = @"quantity"; + if (unit == [HKUnit mileUnit]) { + valueType = @"distance"; + } + NSString *startDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate]; NSString *endDateString = [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate]; @@ -174,7 +179,7 @@ } NSDictionary *elem = @{ - @"quantity" : @(value), + valueType : @(value), @"tracked" : @(isTracked), @"sourceName" : [[[sample sourceRevision] source] name], @"sourceId" : [[[sample sourceRevision] source] bundleIdentifier], -- 2.26.2