【发布时间】:2015-06-29 13:58:35
【问题描述】:
我使用下面的代码让我的应用在后台检测 HealthKit 数据的更新。当这段代码在后台运行时,我的 AppDelegate 的 init 方法会被调用吗? AppDelegate 中的哪些方法会被调用?如果有人可以提供有关后台代码的应用程序生命周期的文档,将不胜感激!
[healthStore enableBackgroundDeliveryForType:type frequency:HKUpdateFrequencyHourly withCompletion:^(BOOL success, NSError *error) {
if (success) {
HKObserverQuery *observerQuery = [[HKObserverQuery alloc] initWithSampleType:type
predicate:nil
updateHandler:^(HKObserverQuery *query, HKObserverQueryCompletionHandler completionHandler, NSError *error) {
if (!error) {
[self retrieveHealthDataWithCompletionHandler:completionHandler];
}
}];
[healthStore executeQuery:observerQuery];
}
【问题讨论】:
标签: ios background-process healthkit