Utilizing the M7 chip in the iPhone5S [closed]

限于喜欢 提交于 2019-12-04 12:55:18

The two main classes you're looking for are CMMotionActivityManager and CMMotionActivity. The first lets you query historical data and manage motion in general. The second gives you access to different, more specific types of motion.

These two classes are available only on iOS 7. Use -[CMMotionActivityManager isActivityAvailable] to determine if motion is available first. I have not found any documentation on it, but my guess is that method will only return YES on devices that have the M7 chip (or future chips that support motion activity reporting).

Chris.Stover

If you are looking for historical data it might be valuable to look into this specific function: queryStepCountStartingFrom:to:toQueue:withHandler: Its part of CMStepCounter which is only available on phones with the M7. From the docs:

This method runs asynchronously, returning immediately and delivering the 
results to the specified handler block. The system stores only the last
seven days worth of step data at most. If there are no samples for the 
specified range of time, a value of 0 is passed to the handler block.

Hopefully this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!