Post not yet marked as solved
Click to stop watching this thread.
You have stopped watching this post. Click to start watching again.
Post marked as unsolved with 2 replies, 0 views
Replied In
magnetometer watch OS 6.2
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 )
}
}