简体   繁体   English

HealthKit数据在后台无法访问

[英]HealthKit data inaccessible in background

I want to pull HealthStore data in the background using background fetch but I keep getting an error: Error Domain=com.apple.healthkit Code=6 "Protected health data is inaccessible" UserInfo=0x17026fdc0 {NSLocalizedDescription=Protected health data is inaccessible} . 我想使用后台提取在后台提取HealthStore数据,但我一直收到错误: Error Domain=com.apple.healthkit Code=6 "Protected health data is inaccessible" UserInfo=0x17026fdc0 {NSLocalizedDescription=Protected health data is inaccessible}

Apple states: Apple声明:

Because the HealthKit store is encrypted, your app cannot read data from the store when the phone is locked. 由于HealthKit存储已加密,因此当手机锁定时,您的应用无法从商店读取数据。 This means your app may not be able to access the store when it is launched in the background. 这意味着您的应用可能无法在后台启动时访问该商店。

Any workaround to access data in the background? 在后台访问数据的任何解决方法? Is the HKObserverQuery the only way to get data in the background? HKObserverQuery是在后台获取数据的唯一方法吗?

As stated in the documentation you quoted there's no way to access HealthKit data while the phone is locked. 如您所引用的文档中所述,在手机锁定时无法访问HealthKit数据。 However, you can access the data if the phone is unlocked and your app is in the background. 但是,如果手机已解锁且您的应用位于后台,则可以访问数据。 So if background fetch happens while the phone is unlocked you will be able to access the data. 因此,如果在手机解锁时发生背景提取,您将能够访问数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM