@@ -19,9 +19,9 @@ class HealthKitDataSync {
19
19
20
20
static let shared = HealthKitDataSync ( )
21
21
fileprivate let maxRetroactiveDays = 1 //day
22
- fileprivate var semaphoreDict = [ String: NSLock] ( ) //settled for lock since one max
22
+ fileprivate var semaphoreDict = [ String: NSLock] ( ) //settled for lock since one max
23
23
24
- func collectAndUploadData( forType type: HKQuantityType , onCompletion: ( ( ) -> Void ) ? ) {
24
+ func collectAndUploadData( forType type: HKSampleType , onCompletion: ( ( ) -> Void ) ? ) {
25
25
26
26
let dispatchGroup = DispatchGroup ( )
27
27
dispatchGroup. enter ( )
@@ -61,7 +61,7 @@ class HealthKitDataSync {
61
61
62
62
extension HealthKitDataSync {
63
63
64
- fileprivate func collectData( forType type: HKQuantityType , _ sourceRevision: HKSourceRevision , onCompletion: @escaping ( ( [ HKSampleData ] ) -> Void ) ) {
64
+ fileprivate func collectData( forType type: HKSampleType , _ sourceRevision: HKSourceRevision , onCompletion: @escaping ( ( [ HKSampleData ] ) -> Void ) ) {
65
65
66
66
let latestSync = getLastSyncDate ( forType: type, forSource: sourceRevision)
67
67
@@ -86,7 +86,7 @@ extension HealthKitDataSync {
86
86
87
87
}
88
88
89
- fileprivate func getSources( forType type: HKQuantityType , onCompletion: @escaping ( ( Set < HKSource > ) -> Void ) ) {
89
+ fileprivate func getSources( forType type: HKSampleType , onCompletion: @escaping ( ( Set < HKSource > ) -> Void ) ) {
90
90
91
91
// find all sources that contain requested data type
92
92
//TODO testing datePredicate, only look through sources that have been active in the last five days... filters out devices that are no longer in use.
@@ -113,7 +113,7 @@ extension HealthKitDataSync {
113
113
114
114
extension HealthKitDataSync {
115
115
116
- fileprivate func getLastSyncItem( forType type: HKQuantityType , _ sourceRevision: HKSourceRevision ) -> Results < HealthKitDataUploads > {
116
+ fileprivate func getLastSyncItem( forType type: HKSampleType , _ sourceRevision: HKSourceRevision ) -> Results < HealthKitDataUploads > {
117
117
118
118
let realm = try ! Realm ( )
119
119
let syncMetadataQuery = NSCompoundPredicate (
@@ -145,7 +145,7 @@ extension HealthKitDataSync {
145
145
}
146
146
147
147
// maybe throw a default date here?
148
- fileprivate func getLastSyncDate( forType type: HKQuantityType , forSource sourceRevision: HKSourceRevision ) -> Date {
148
+ fileprivate func getLastSyncDate( forType type: HKSampleType , forSource sourceRevision: HKSourceRevision ) -> Date {
149
149
150
150
let lastSyncMetadata = getLastSyncItem ( forType: type, sourceRevision)
151
151
if let lastSyncItem = lastSyncMetadata. first {
@@ -156,7 +156,7 @@ extension HealthKitDataSync {
156
156
return Date ( ) . dayByAdding ( - maxRetroactiveDays) ! // Q: what date should we put?
157
157
}
158
158
159
- fileprivate func setLastSyncDate( forType type: HKQuantityType , forSource sourceRevision: HKSourceRevision , date: Date ) {
159
+ fileprivate func setLastSyncDate( forType type: HKSampleType , forSource sourceRevision: HKSourceRevision , date: Date ) {
160
160
161
161
let realm = try ! Realm ( )
162
162
let lastSyncMetadata = getLastSyncItem ( forType: type, sourceRevision)
@@ -167,7 +167,7 @@ extension HealthKitDataSync {
167
167
}
168
168
}
169
169
170
- fileprivate func queryHealthStore( forType type: HKQuantityType , forSource sourceRevision: HKSourceRevision , fromDate startDate: Date , queryHandler: @escaping ( HKSampleQuery , [ HKSample ] ? , Error ? ) -> Void ) {
170
+ fileprivate func queryHealthStore( forType type: HKSampleType , forSource sourceRevision: HKSourceRevision , fromDate startDate: Date , queryHandler: @escaping ( HKSampleQuery , [ HKSample ] ? , Error ? ) -> Void ) {
171
171
172
172
let sortDescriptor = NSSortDescriptor ( key: HKSampleSortIdentifierStartDate, ascending: true )
173
173
0 commit comments