Search code examples
ioscore-motionapple-m7

CMMotionActivityManager ignores cycling


I've been researching the new M7 chip's CMMotionActivityManager, for determining whether the user of the device is walking, running, in a car, etc (see Apple Documentation). This seemed like a great step forward over trying to determine this previous from using LocationManager and accelerometer data only.

I notice however that CMMotionActivityManager does not have a cycling activity, which is disappointing, and almost a deal-breaker for complete usage as a new activity manager. Has anyone else found a convenient way to use CMMotionActivityManager with cycling also without having to reincorporate CMLocationManager + accelerometer just to try to test for cycling too?

Note, this also does not include general transport options for things like a Train. For instance, I commute an hour a day on the train. Automotive could be made more generic at least, similar to how Moves uses Transport.

CMMotionActivity has these defined motion types only:

  • stationary
  • walking
  • running
  • automotive
  • unknown

Useful notes from Apple's code, that does not necessarily solve the issue, but is helpful:

CMMotionActivity

An estimate of the user's activity based on the motion of the device.

The activity is exposed as a set of properties, the properties are not mutually exclusive.

For example, if you're in a car stopped at a stop sign the state might look like: stationary = YES, walking = NO, running = NO, automotive = YES

Or a moving vehicle, stationary = NO, walking = NO, running = NO, automotive = YES

Or the device could be in motion but not walking or in a vehicle. stationary = NO, walking = NO, running = NO, automotive = NO. Note in this case all of the properties are NO.

[Direct Source: Apple iOS Framework, CoreMotion/CMMotionActivity.h @interface CMMotionActivity, inline code comments]


Solution

  • So, not sure if you still need an answer to that but here is the latest from iOs8 SDK

    @property(readonly, nonatomic) BOOL cycling NS_AVAILABLE(NA, 8_0);