Search code examples
iosobjective-ccore-locationcore-motioncmmotionmanager

How to use CMDeviceMotion to detect how fast my device is traveling?


I am writing an iOS app and don't want to start detecting for shake events until after my device has reached a certain speed. I know how to use CMMotionManager to get the CMAccelerationData to detect for shake events but does anyone know what i should use to detect how fast my device is moving? Either CMDeviceMoting/userAcceleration/GPS... i am just cannot find what i should do. I am writing my app in swift but answers in Objective-C will suffice as well.

Thank you for your help


Solution

  • You could use CoreLocation and use a CLLocation's speed property. This requires the device's GPS, and will only work for somewhat large speeds.