To read sensor data from AirPods Pro

Which API can I use to read the real-time sensor data from AirPods Pro for head tracking?

Replies

You are looking for CMHeadphoneMotionManager

https://developer.apple.com/documentation/coremotion/cmheadphonemotionmanager
Hello, Gualtier,

Could you please confirm whether this would also be working with "normal" AirPods?

As mentioned in this thread, it is working properly by now for AirPods Pro: https://developer.apple.com/forums/thread/650051

Since my 2nd generation AirPods and AirPods Pro are having the same firmware versions, is there any hardware missing which will prevent them from working with this API?

Thank you very much.
Hi, what you're looking for is the CMSHeadphoneMotionManager API in CoreMotion.
You can find the Apple documentation here.
https://developer.apple.com/documentation/coremotion/cmheadphonemotionmanager

I also found a sample on Github.
https://github.com/tukuyo/AirPodsPro-Motion-Sampler
@haptic - The CMHeadphoneMotionManager only functions with AirPods Pro (this was mentioned in a WWDC session, which I'm having trouble finding, but I do recall it in mind). I am not from Apple and cannot comment as to whether or not the functionality could/would/should exist on other AirPods, but I would recommend starting with the isDeviceMotionAvailable check in your app before allowing motion tracking to begin.