Does disableBackgroundDeliveryForType disable the corresponding HKObserverQuery?
In HealthKit, you create an HKObserverQuery, execute it, and then enableBackgroundDeliveryForType.
let backgroundQuery:HKObserverQuery = HKObserverQuery(sampleType: quantityType, predicate: nil) { (query, complete, error) -> Void in
}
self.healthKitStore.executeQuery(backgroundQuery)
self.healthKitStore.enableBackgroundDeliveryForType(
quantityType,
frequency: .Immediate,
withCompletion: { (success, error) -> Void in
if !success {
println(error)
}
})
I am wondering if I can call disableBackgroundDeliveryForType, will it just disable the registered HKObserverQuery or will it also remove it?
+3
source to share
1 answer
Disabling background delivery will not stop the observer request. It only prevents your application from being resumed in the background to receive information about new samples. When your application is in the foreground, your user request updateHandler
will continue to run when new data arrives. You must call HKHealthStore.stopQuery(backgroundQuery)
to stop him.
+5
source to share