3

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?

Dan
  • 12,157
  • 12
  • 50
  • 84
Woodstock
  • 22,184
  • 15
  • 80
  • 118

2 Answers2

6

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

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
  • Really great thanks, so just to follow up, using these two classes I am directly using the m7? but using other core motion classes/apis I am not? Finally I thought the M7 was for all core motion info gps/compass/accelerometer/gyro however it looks like it only gives it benefits to the two above classes? thanks again. Do Apple have any kind of intro to M7 development? – Woodstock Oct 28 '13 at 18:30
  • 1
    These classes need the M7 to function. However, I believe all Core Motion work is now done on the M7, so any other classes you use will probably use the M7 as well, if it's available. If it's not available, those classes will probably fall back on their older implementations using the A chip series. The closest thing to an M7 Programming Guide would probably be the Core Motion programming guide, because Core Motion uses M7 in its implementation and the user has no way of directly accessing the M7--only through Core Motion. – Scott Berrevoets Oct 28 '13 at 18:34
  • This is very interesting, so I guess (except for battery life) the M7's flagship feature is this ability to count steps that wasn't there before right? – Woodstock Oct 28 '13 at 18:41
  • 1
    @JohnWoods: Pretty much, although it makes things like detecting automative movement a lot easier. This could be done before (checking the user's speed, making assumptions based on that, etc.), but now it's simply a property on CMMotionActivity. – Scott Berrevoets Oct 28 '13 at 18:46
  • Thanks a lot Scott. Really appreciate this info. – Woodstock Oct 28 '13 at 19:24
1

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!

Ankur Arya
  • 4,693
  • 5
  • 29
  • 50
Chris.Stover
  • 516
  • 6
  • 14