public IPromise <List <StepSample> > ReadSteps(DateTimeOffset startDate, DateTimeOffset endDate) { Promise <List <StepSample> > promise = new Promise <List <StepSample> >(); List <StepSample> allPeriods = new List <StepSample>(); if (isReading) { Debug.LogWarning("can't read steps right now, because another process is reading at the same time "); promise.Dispatch(allPeriods); } else { Debug.Log($"reading quantity samples from date: {startDate:yyyy-MM-dd} to now {endDate:yyyy-MM-dd HH:mm ss}"); this.healthStore.ReadQuantitySamples(HKDataType.HKQuantityTypeIdentifierStepCount, startDate, endDate, delegate(List <QuantitySample> samples) { foreach (QuantitySample sample in samples) { Debug.Log($"{sample.startDate:yyyy-MM-dd HH:mm} to {sample.endDate:yyyy-MM-dd HH:mm} steps {(int)sample.quantity.doubleValue}"); allPeriods.Add(StepSample.FromQuantitySample(sample)); } promise.Dispatch(allPeriods); });
static void Main(string[] args) { //SimpleSample.Create(); StepSample.Create(); //FeatureSample.Create(); }