Skip to content

Commit

Permalink
Fix iOS availability
Browse files Browse the repository at this point in the history
  • Loading branch information
christophhagen committed Feb 9, 2024
1 parent 2e9ce5e commit 4c2e4eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/HealthKitExtensions/HKHealthStore+Samples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ extension HKHealthStore {
try await requestAuthorization(toShare: typesToShare, read: typesToRead)
}

@available(iOS 15.4, *)
public func read<T>(predicate: NSPredicate? = nil, sortDescriptors: [SortDescriptor<HKQuantitySample>], limit: Int? = nil) async throws -> [T] where T: HKQuantitySampleContainer {

let descriptor = HKSampleQueryDescriptor(
Expand All @@ -139,6 +140,7 @@ extension HKHealthStore {
return results.map { T.init(sample: $0) }
}

@available(iOS 15.4, *)
public func read<T>(predicate: NSPredicate? = nil, sortDescriptors: [SortDescriptor<HKCorrelation>], limit: Int? = nil) async throws -> [T] where T: HKCorrelationContainer {

let descriptor = HKSampleQueryDescriptor(
Expand All @@ -150,6 +152,7 @@ extension HKHealthStore {
return results.map { T.init(sample: $0) }
}

@available(iOS 15.4, *)
public func read<T>(predicate: NSPredicate? = nil, sortDescriptors: [SortDescriptor<HKCategorySample>], limit: Int? = nil) async throws -> [T] where T: HKCategorySampleContainer {

let descriptor = HKSampleQueryDescriptor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ final class HealthKitExtensionsTests: XCTestCase {
try await store.requestAuthorization(toShare: HKCategoryType.writableTypes, read: HKCategoryType.readableTypes)
}

@available(iOS 15.4, *)
func testReadData() async throws {
let store = HKHealthStore()
let predicate = HKQuery.predicateForSamples(withStart: now, end: now, options: [])
Expand Down

0 comments on commit 4c2e4eb

Please sign in to comment.