magnetometer watch OS 6.2

Dear all,

I am trying to get data from the magnetometer in my watch series 5.

I am trying to see is the magentometer is available using


motionManager.isMagnetometerAvailable


that always return a false value.


Can I access to raw magnetometer data in the watch?

I have the same issue. Have you found a solution yet?

I've also had this question and after contacting Code Level Support got the answer.

Reference frame should be used to get magnetometer data. For example:

self.motionManager.startDeviceMotionUpdates(using: CoreMotion.CMAttitudeReferenceFrame.xMagneticNorthZVertical, to: .main) { (deviceMotionData, error) in
    guard error == nil else {
         print(error!)
        return
    }

    if let motionData = deviceMotionData {

         let x = motionData.magneticField.field.x
         let y = motionData.magneticField.field.y
         let z = motionData.magneticField.field.z
         let h = motionData.heading

         print(x, y, z)
         print(h )
         print(motionData.magneticField.accuracy.rawValue )
    }
}
magnetometer watch OS 6.2
 
 
Q