How to determine if M7 is present, aka is iPhone 5S or newer?

Trying to find a way to detect M7.

Doesn't it make sense to request a CMStepCounter or CMMotionActivity class if M7 is missing? I assume that on models without M7 that have iOS 7.0, these classes receive data, but not as efficiently and use a lot more battery.

In a rough way would be:

struct utsname systemInfo; uname(&systemInfo); model = [[NSString alloc] initWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; version = [[NSString alloc] initWithString:[[UIDevice currentDevice] systemVersion]]; if ([model compare:@"iPhone6,1"]) { } 
+7
ios sdk core-motion apple-m7
source share
1 answer

Use the APIs that Apple provides:

 if ([CMStepCounter isStepCountingAvailable]) { // The device supports step counting } else { // The device does not support step counting } if ([CMMotionActivityManager isActivityAvailable]) { // You can use CMMotionActivity } else { // Nope, not supported } 

Of course, this API only works on iOS 7 or later. Therefore, if you need to support iOS 5 or 6, you also need to wrap this code in a check for the CMStepCounter class.

+17
source share

All Articles