I have been playing with CoreMotion for a while right now but I'm facing a problem in detecting device's movements. What I wanted to achieve is detecting my iPhone's movements when on flat surface. I want to know if it's moving to the right or to the left that's all. Imagine a mouse and it's cursor. I'm trying to achieve the same thing, I just want to know if the device is moving to the right or to the left that's all.
I've tried to get Accelerometer's data on X-Axis, but that was not helpful, theoretically, if the value is positive it should be moving to the right & if negative it should be moving into the left. But that was not the case at all.
if let accData = self.motionManager.accelerometerData {
if accData.acceleration.x > 0 {
print("Right...")
}else if accData.acceleration.x < 0 {
print("Left.....")
}
}