Ejemplo n.º 1
0
        private async Task DeleteSamples(Measure measure)
        {
            if (_suppressed)
            {
                return;
            }

            var predicate = HKQuery.GetPredicateForMetadataKey(
                HKMetadataKey.ExternalUuid,
                new[] { NSObject.FromObject(MetadataKey.GetExternalUUID(measure.Id)) });

            var result = await _healthStore.DeleteObjectsAsync(
                HKQuantityType.Create(HKQuantityTypeIdentifier.BloodGlucose),
                predicate);

            if (!result.Item1)
            {
                _log.Warn($"Can't delete blood glucose data by reason: {result.Item2.LocalizedDescription}");
            }

            result = await _healthStore.DeleteObjectsAsync(
                HKQuantityType.Create(HKQuantityTypeIdentifier.InsulinDelivery),
                predicate);

            if (!result.Item1)
            {
                _log.Warn($"Can't delete insulin data by reason: {result.Item2.LocalizedDescription}");
            }
        }