尝试在watchOS上进行授权。出现此错误:
2019-03-20 18:32:45.859857-0600 iRun WatchKit扩展[21129:1854743] [默认] containerAppExtensionEntitlementsWithCompletion:失败,错误:(空)
我的App和Watch Extension的功能均已为HealthKit启用。
这里有一个类似的问题要问,但没有人回答。无法找到任何方法来解释此错误?
我要授权的代码:
if HKHealthStore.isHealthDataAvailable() {
let healthStore = HKHealthStore()
let heartRateQuantityType = HKObjectType.quantityType(forIdentifier: .heartRate)!
let allTypes = Set([HKObjectType.workoutType(),
heartRateQuantityType
])
healthStore.requestAuthorization(toShare: nil, read: allTypes) { (success, error) -> Void in
if success == false {
print("Error")
}
}
}
对于我的应用程序中的AppDelegate.swift:
func applicationShouldRequestHealthAuthorization(_ application: UIApplication) {
let healthStore = HKHealthStore()
healthStore.handleAuthorizationForExtension { (success, error) -> Void in
}
}