Search code examples
iosobjective-ciphonecore-motion

CMPedometer StepCounting not Available


My code is:

if ([CMPedometer isStepCountingAvailable]) {

        self.pedometer = [[CMPedometer alloc] init];
    }
    else {
        NSLog(@"Step counting is not available on this device!");
        [SVProgressHUD showErrorWithStatus:@"Step counting is not available on this device!"];
    }

When i run it on iOS8 and later devices, it says:

Step counting is not available on this device!

How can i make it available for step counting ?


Solution

  • Your code is correct and it yields the expected result. The iPhone 5 does not have the hardware (the Apple M7 chip) to track steps, so step counting is not available.

    You need at least an iPhone 5s