我已经为 HealthKit 数据和所需的一切启用了后台传送。唯一让我困惑的是,当健康应用程序有一些更新时,我会在哪里收到通知。在 enableBackgroundDelivery
方法的完成处理程序中或在应用程序启动时在应用程序委托(delegate)中。
最佳答案
补全只给出enable是否成功,来自Doc HealthKit
HealthKit wakes your app whenever new samples of the specified type are saved to the store. Your app is called at most once per time period defined by the specified frequency.
As soon as your app launches, HealthKit calls the update handler for any observer queries that match the newly saved data. If you plan on supporting background delivery, set up all your observer queries in your app delegate’s application(:didFinishLaunchingWithOptions:) method. By setting up the queries in application(:didFinishLaunchingWithOptions:), you ensure that the queries are instantiated and ready to use before HealthKit delivers the updates.
关于ios - enableBackgroundDelivery(对于 :frequency:withCompletion:) HealthKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48670418/