skip to Main Content

I’ve been waiting to try these APIs. I had already tried them on Beta with no luck and thought on release I would be able to use them. Today I tried with xCode 15 and any calls to start something from the CMBatchedSensorManager will result in a crash after a few seconds on the thread:

Thread 7 Queue : com.apple.tcc.kTCCServiceMotion (serial)

No error message, just crash.

Am I doing something wrong?

Update:

I had read somewhere that HealthKit is required but then forgotten about it. However, I tried now with adding capabilities to both my iOS and watchOS project. I still don’t get it working.

I call HKHealthStore.isHealthDataAvailable() and can see it’s available on both my devices. I create let healthStore = HKHealthStore() in my App class even though I don’t use it.
Then when I call

private let batchedMotion = CMBatchedSensorManager()

func startBatchUpdate() {
    print("starting")
    batchedMotion.startDeviceMotionUpdates { (x, e) in
        print("started")
        print(x)
    }

It takes a while and then crashes.

enter image description here

Update 2:
I was finally able to call the apis without getting a crash by adding
Privacy – Motion Usage Description in info.plist.
It would be really nice if I had an error message, I just guessed this this time.

However, I get no data and I get an Error. The block parameters x: [CMDeviceMotion]?,
e: Error? gives me nil on the x and for the error I get:

"The operation couldn’t be completed. (CMErrorDomain error 109.)"

2

Answers


  1. Chosen as BEST ANSWER

    You need

    1 - HealthKit

    2 - Privacy - Motion Usage Description in info.plist

    3 - Active workout session


  2. This is a workout centric API, this means that you need an active HealthKit workout session. Do you have one active when trying to get the batched sensor data?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search