If you're looking to develop based on raw or processed gyroscope data then Core Motion is helpful
https://developer.apple.com/documentation/coremotion
"For example, a game might use accelerometer and gyroscope input to control onscreen game behavior."
The part specifically about obtaining headphone orientation is here (added in 2023):
https://developer.apple.com/documentation/coremotion/cmheadp...