diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.m b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.m index 8a8a67c6c06c052b4e6df21105b87166ac8bbfbe..3fe42f0ebfdb7e5f3bb39e9e1e6471274f14deca 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Mindfulness.m @@ -14,6 +14,7 @@ - (void)mindfulness_saveMindfulSession:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback { + double value = [RCTAppleHealthKit doubleFromOptions:input key:@"value" withDefault:(double)0]; NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; @@ -22,14 +23,8 @@ return; } - // original - HKQuantity *quantity = [HKQuantity quantityWithUnit:unit doubleValue:value]; - HKQuantityType *type = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount]; - HKQuantitySample *sample = [HKQuantitySample categorySampleWithType:type quantity:quantity startDate:startDate endDate:endDate]; - - // new HKCategoryType *type = [HKCategoryType categoryTypeForIdentifier: HKCategoryTypeIdentifierMindfulSession]; - HKCategorySample *sample = [HKCategorySample categorySampleWithType:type value:nil startDate:startDate endDate:endDate]; + HKCategorySample *sample = [HKCategorySample categorySampleWithType:type value:value startDate:startDate endDate:endDate]; [self.healthStore saveObject:sample withCompletion:^(BOOL success, NSError *error) {