When obtaining the magnetic north vector from the magnetometer on iOS there are three ways I know of to do it. Only the first method appears to give reasonable results. The phone is flat on it's back and it's long axis is pointing 97° E according to the Compass app.
CLLocationManagerdelegate overloaddidUpdateHeading. This givesCLHeadingwith(x,y,z)vector of(-18.4, -15.3 -44.9)along with other helpful items such as magnetic/true heading, accuracy, timestamp.
This seems reasonable!
CMMotionManagerstartMagnetometerUpdates. This givesCMMagneticFieldwith(x,y,z)vector of(36.5, -10.1, -375). To be clear, the Z-axis value is negative three hundred and seventy five microteslas. This does not seem reasonable. If I rotate the phone thezvalue fluctuates, but not below-283and that's when the phone is inverted from where it provided the result above.
Is this the internal magnetic field that has not yet been filtered out?
CMMotionManagerstartDeviceMotionUpdates. This givesCMCalibratedMagneticFieldwith propertyfieldwith(x,y,z)vector of(0.0, 0.0, 0.0). This seems to be returning no meaningful data, although the events are firing rapidly and consistently.
Why isn't this returning any values?