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.
CLLocationManager
delegate overloaddidUpdateHeading
. This givesCLHeading
with(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!
CMMotionManager
startMagnetometerUpdates
. This givesCMMagneticField
with(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 thez
value fluctuates, but not below-283
and 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?
CMMotionManager
startDeviceMotionUpdates
. This givesCMCalibratedMagneticField
with propertyfield
with(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?