简体   繁体   English

HealthKit requestAuthorization返回代码100:“授权会话超时”

[英]HealthKit requestAuthorization returns code 100: “Authorization session timed out”

All of my HealthKit authorization requests are timing out with this error. 我所有的HealthKit授权请求都因此错误而超时。 Nothing in my code has changed, but I recently switched Xcode over to a new Apple ID account. 我的代码没有任何变化,但是最近我将Xcode切换到了新的Apple ID帐户。

I have a development team setup, a provisioning profile configured, and the HealthKit Capability and Entitlement working. 我有一个开发团队设置,已配置了配置文件,并且运行了HealthKit功能和权利。 My app builds and runs fine, but any time I make a requestAuthorization call, I get a timeout for no apparent reason. 我的应用程序可以正常构建和运行,但是每当我进行requestAuthorization调用时,我都不会因明显的原因而超时。 There's no additional information in the error, and everything appears to be configured properly, so I'm pretty lost on what could cause this. 错误中没有其他信息,所有内容似乎都已正确配置,所以我对可能导致此问题的原因完全迷失了。

I've tried both simulators and devices with the same issue. 我已经尝试过相同问题的模拟器和设备。 The dialog for HealthKit auth never appears. HealthKit身份验证对话框永远不会出现。 I can go into the Health app after the fact and turn on the necessary data sharing, but this is a not an acceptable workaround. 事实结束后,我可以进入“健康”应用程序并打开必要的数据共享,但这是不可接受的解决方法。

What can cause healthKitStore requestAuthorization timeout errors? 什么会导致healthKitStore requestAuthorization超时错误?
I am 99% sure this is a configuration issue, but having gone through the process multiple times, and re-created numerous certs, provisioning profiles etc, I don't know what the problem could be. 我99%确信这是一个配置问题,但是经过多次处理,并重新创建了许多证书,配置文件等,我不知道可能是什么问题。 Where should I be looking for config issues? 我应该在哪里寻找配置问题? There is essentially zero documentation on this, and I've only found 2 results on Google related to this with no solutions. 关于此的文档基本上为零,而我在Google上仅发现2个与此相关的结果,但没有解决方案。

let healthKitTypesToRead = [...]
let healthKitStore:HKHealthStore = HKHealthStore()

healthKitStore.requestAuthorization(toShare: nil, read: healthKitTypesToRead) { (success, error) -> Void in
    if( completion != nil ) {
        completion(success, error as? NSError)
    }
}

This was due to running the authorization request in a background thread. 这是由于在后台线程中运行授权请求。 Doing it on the main thread solved the problem. 在主线程上执行此操作可以解决该问题。

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

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