【问题标题】:Health kit still return deleted data when I use Delete All action from Health App当我使用 Health App 中的 Delete All 操作时,Health kit 仍会返回已删除的数据
【发布时间】:2017-05-14 15:29:42
【问题描述】:

我正在使用 Health Kit 从 Health App 获取血压,我有一个奇怪的行为: 我从健康应用程序添加了一个新数据,它正确显示在我的客户端应用程序上,当我使用 Delete All 操作从健康应用程序中删除该数据时,我的客户端应用程序仍然返回它。但是当我单独删除相同的数据时(在单元格上向左滑动并单击删除按钮),我的客户端应用程序不会返回数据。 我正在寻找的正确行为是当健康 App 上没有数据时,我的客户端 App 也应该不显示数据。

这是我的代码:

[self.healthStore  requestAuthorizationToShareTypes:nil readTypes:[self dataTypesToRead] completion:^(BOOL success, NSError *error) {
    if (success) {
                HKSampleType *sampleType = [HKSampleType quantityTypeForIdentifier:HKQuantityTypeIdentifierBloodPressureSystolic];

        NSPredicate *predicate = [HKQuery predicateForSamplesWithStartDate:startDate endDate:endDate options:HKQueryOptionNone];

        HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:sampleType predicate:predicate limit:0 sortDescriptors:nil resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
            if (!results) {
                NSLog(@"An error occured. The error was: %@.", error);
                abort();
            }

            dispatch_async(dispatch_get_main_queue(), ^{
                NSLog(@"results: %@.", results);


            });

        }];

        [self.healthStore executeQuery:query];

    }

}];

【问题讨论】:

    标签: ios objective-c healthkit hkhealthstore hksamplequery


    【解决方案1】:

    这似乎是 iOS 中的一个错误,不是您可以通过更改应用程序代码来解决的问题。你应该file a radar Apple。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-18
      • 2021-11-18
      相关资源
      最近更新 更多