I want to calculate user steps(like pedometer).I know that with iPhone 5s, 6 and 6+ we can use CMStepCounter or CMPedometer class(which use M7 chip of devices) but iPhone 5 and lower versions does not support M7 chip, so we can't use CoreMotion. By searching all over internet i came to know that we can use accelerometer sensor for this purpose. But after spending a lot of time still i'm not able to make an accurate algorithm that works.
Edit2: After spending several days on searching google i tried a lot but still unable to find an working algorithm for counting user step using accelerometer. Can anybody out there who can help me?
CMMotionManager is what you are looking for if you are using later versions of iOS. However, if you want to continue with iOS 5 or lower you need to use the following although this is deprecated.
The method where you can get x, y, z values is:
If you need to know the logic behind step counter you can search and read through in Google :)