【发布时间】:2019-04-08 10:04:30
【问题描述】:
我有一个 iOS 应用程序,它会在 Fitbit、Mi Band 3 等第三方设备更新时读取 HealthKit 数据(心率)。目前,只要数据源是这些 3rd 方健康设备,我就可以从 HealthKit 以前台和后台模式读取这些数据。但是,当 iWatch 更新 HealthKit 时,我无法读取任何内容。
看来我需要授权我的 iOS 应用访问 iWatch 数据。有一个需要访问数据的所有应用程序的列表。该列表当前为空,这意味着我的应用程序没有此访问权限。请参考附图。
我已经实现了 iOS 应用读取 HealthKit 的授权。我使用“功能”启用了 HealthKit,并将隐私选项添加到 Info.pList 至此,授权iOS读取HealthKit的代码如下:
let readDataTypes : Set = [HKObjectType.quantityType(forIdentifier: .heartRate)!]
HKStore.requestAuthorization(toShare: nil, read: readDataTypes) { (success, error) in
guard success else{
print("error \(String(describing: error))")
return
}
我想为我的应用提供从 HeathKit 访问 iWatch 数据的授权。任何文档、链接和指导将不胜感激。
【问题讨论】:
-
这个方法你查了吗
open func handleAuthorizationForExtension(completion: @escaping (Bool, Error?) -> Void) -
您好,Prashant,感谢您的回复。我在 iOS 授权后添加了上述功能。但是,授权的 iWatch 列表仍然是空的。是否有更多关于 iOS 应用出现在已批准应用列表中的建议?
标签: ios swift watchkit apple-watch healthkit