本文介绍了如何使用healthkit解决此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ios Swift应用程序中添加了healthkit的代码,但是我收到了错误...

I'm adding code for healthkit in my ios Swift app, but I'm getting an error...

 /* Ask for permission to access the health store */
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

if HKHealthStore.isHealthDataAvailable(){

  healthStore.requestAuthorizationToShareTypes(typesToShare,
    readTypes: typesToRead,
    completion: {(succeeded: Bool, error: NSError!) in

      if succeeded && error == nil{
        println("Successfully received authorization")
      } else {
        if let theError = error{
          println("Error occurred = \(theError)")
        }
      }

    })

} else {
  println("Health data is not available")
}

}



怎么能解决这个问题?

谢谢!

推荐答案

以上两个答案应该先试试。但是

Both of the above answers should be tried first. If however


  1. 您确定该功能已被激活

  2. 您对自己的应用充满信心与您的配置文件相关联的ID已启用healthkit并与应用的包ID匹配

然后尝试强制构建使用该特定配置通过选择目标并转到

Then try and force the build to use that specific provisioning profile by selecting your target and going to

构建设置 - >代码签名 - >配置文件

build settings -> code signing -> provisioning profile

并选择手动。

如果使用自动选择,我遇到了在调试中出现上述错误的情况

I've run into cases where get the above error in debug if 'automatic selection' is being used

这篇关于如何使用healthkit解决此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 13:51