Utilizing the M7 chip in the iPhone5S

2.4k views Asked by At

I was wondering if anyone can point me in the right direction with regard to utilzing the M7 chip in the iPhone5S and above.

I was wondering if it's just automagically used when you use general core motion APIs or is there a specific set of APIs to use?

Finally I noted whilst reading some articles online that it keeps some historical movement data, anyone know how to access this or can anyone point me in the right direction?

2

There are 2 answers

5
Scott Berrevoets On BEST ANSWER

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).

1
Chris.Stover On

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!