Tracking user rotation using CoreMotion

Hi all,

I’m currently trying to use CoreMotion to track a user moving around an object.

The user will have his iPhone in landscape right orientation pointing to said object.
I basically want to track the full 360 rotation of the user walking around the object and know when he gets back to the starting point.

I’ve read that I should use Quaternions in order to avoid Gimbal lock, but I have know idea on how to calculate the rotation using CMQuaternion from CoreMotion.

How would I actually go about calculating this rotation?
Any help would greatly be appreciated.