Why is accelerometer:didAccelerate: deprecated in IOS5?

I did not yet use iOS 5, but already in 4.x UIAccelerometer and UIAccelerometerDelegate were replaced by the CoreMotion framework. It is more sophisticated, takes gyroscope signals into account and performs a sensor fusion i.e. does calibrating stuff like bias calculation for you.

Basically the CMDeviceMotionHandler block callback is now the equivalent. It is called every deviceMotionUpdateInterval seconds or you can go with your own timer loop and pull the data. It is pretty straightforward and easy to use. Look at Simple iPhone motion detect and follow the three links to the SDK docs.

There are three things you have to bear in mind:

  • Working with Device Motion requires iPhone version >= 4 or newest iPod touch generation because it relies on gyroscope support
  • When using Device Motion you must not use low pass filtering to extract gravity because it is done for you
  • If you want to support older hardware, you have to work with raw data. This is done by creating a CMAccelerometerHandler and calling startAccelerometerUpdatesToQueue:withHandler:. Then you have to extract gravity with low pass filtering like in didAccelerate

Leave a Comment