在 watchOS 4 Beta 4 中将数据插入 HKWorkoutRouteBuilder 时出现令人费解的错误

jef*_*ley 3 healthkit watchos-4

当我将路线数据插入 HKWorkoutRouteBuilder 时,出现以下错误:

与名为 com.apple.healthd.server 的服务的连接中断,但消息是通过其他代理发送的,因此该代理已失效

这是一个代码片段。

    workoutRouteBuilder.insertRouteData(filteredLocations) { (success, error) in
        if !success {
            print("inserting route data failed with error: \(String(describing: error))")
        }
    }
Run Code Online (Sandbox Code Playgroud)

我通过 Speed Sloth 示例中的 imelementation 进行了模式化。

任何见解将不胜感激!

更新:以下是监视日志中的更多信息。看起来像是某种权限问题,但我还没有找到它:

故障 13:21:14.664262 -0400 来自 pid 1705 的健康连接:警告:在调用收到的消息期间捕获异常,丢弃传入消息并使连接无效。例外:无效参数不满足:[authorizationStatuses count] == [typesInducingParentTypes count] 无效参数不满足:[authorizationStatuses count] == [typesInducingParentTypes count](0 CoreFoundation
0x1dc04d25 + 153 1 libobjc.A.dylib
0x1d22718ion objcthrow
0x1dc04be5 + 1 3 基金会
0x1e43c1cd + 93 4 HealthDaemon
0x2edf678f + 2015 5 HealthDaemon
0x2ee6eed1 + 143 6 HealthDaemon
0x2ee6ec77 + 143 7 HealthDaemon
0x2ee7b99b + 485 8 HealthDaemon
0x2f0e1e1f + 143 9 基础
0x1e589393 + 19 10 基础
0x1e587<…>

Lew*_*s42 6

我有同样的问题。您需要确保向用户请求授权:

// Objective C
[HKSeriesType workoutRouteType]

// Swift
HKSeriesType.workoutRoute()
Run Code Online (Sandbox Code Playgroud)

  • 谢谢!成功了!我不敢相信我错过了那个。当然,更具描述性的错误消息会更好。 (3认同)