containerAppExtensionEntitlementsWithCompletion:失败,错误:(空)

时间:2019-03-21 00:36:52

标签: swift xcode swift3 watch-os-2 health-kit

尝试在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

        }
    }

0 个答案:

没有答案