2017-08-01 65 views
2

當我插入數據路由到HKWorkoutRouteBuilder我得到以下錯誤:令人費解的錯誤數據插入HKWorkoutRouteBuilder在watchOS 4 Beta 4的

以服務命名com.apple.healthd.server的連接被中斷,但該消息是通過一個額外的代理髮送,因此這個代理已經失效

這是一段代碼。

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

我通過Speed Sloth示例中的驅動進行了圖案化。

任何見解將不勝感激!

更新: 以下是一些有關手錶日誌的更多信息。看起來像是某種權限問題的,但我一直沒能追查尚未:

fault 13:21:14.664262 -0400 healthd connection from pid 1705: Warning: Exception caught during invocation of received message, dropping incoming message and invalidating the connection. Exception: Invalid parameter not satisfying: [authorizationStatuses count] == [typesIncludingParentTypes count] Invalid parameter not satisfying: [authorizationStatuses count] == [typesIncludingParentTypes count] ( 0 CoreFoundation
0x1dc04d25 + 153 1 libobjc.A.dylib
0x1d227181 objc_exception_throw + 39 2 CoreFoundation
0x1dc04be5 + 1 3 Foundation
0x1e43c1cd + 93 4 HealthDaemon
0x2edf678f + 2015 5 HealthDaemon
0x2ee6eed1 + 143 6 HealthDaemon
0x2ee6ec77 + 143 7 HealthDaemon
0x2ee7b99b + 485 8 HealthDaemon
0x2f0e1e1f + 143 9 Foundation
0x1e589393 + 19 10 Foundation
0x1e587<…>

回答

2

我有同樣的問題。你需要確保你從用戶申請授權:

// Objective C 
[HKSeriesType workoutRouteType] 

// Swift 
HKSeriesType.workoutRoute() 
+0

謝謝!這就是訣竅!我不能相信我錯過了這一點。當然,更具描述性的錯誤信息會很好。 – jeffbailey

+0

同意的錯誤應該改進。此外,當用戶必須授予位置訪問權限才能使其成爲有用的權限時,它似乎需要將權限重載作爲權限。 PS可以隨意將此作爲接受的答案;) – Lewis42

1

The connection to service named com.apple.healthd.server was interrupted, but the message was sent over an additional proxy and therefore this proxy has become invalid

見此消息表明系統進程處理該請求已經崩潰或退出。你應該向Apple提交一個bug。查找健康的崩潰日誌並將其包含在內。

+0

是否有可能獲得從模擬器'healthd' crashlogs?我無法在控制檯中找到對「healthd」的任何引用。 – Lewis42

0

不要忘記在AppDelegate中

爲HKHealthStore添加WorkoutRoute請求

鍛鍊路線不帶模擬器的工作,只有一些工作HKWorkoutActivityType像 .walking,.running上OS4

private func requestAccessToHealthKit() { 

    let healthStore = HKHealthStore() 

    let allTypes = Set([HKObjectType.workoutType(), 
         HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)!, 
         HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning)!]) 
    if #available(watchOS 4.0, *) { 
     allTypes.insert(HKSeriesType.workoutRoute()) 
    } 
    healthStore.requestAuthorization(toShare: allTypes, read: allTypes) { (success, error) in 
     if !success { 
      print(error?.localizedDescription ?? "") 
     } 
    } 
}