Knowing .NET Sometimes a coder who writes, sometimes a writer who codes. Formerly, a coder who edited magazines.

October 7, 2013

My Favorite iOS 7 APIs Part 3 : CoreMotion (iPhone 5S only)

Filed under: C#,iOS,Xamarin — larry @ 11:03 am

The new M7 coprocessor in the iPhone 5S makes pedometer apps trivial:

    if(CMStepCounter.IsStepCountingAvailable)
    {
        var counter = new CMStepCounter();
        //Last 8 hours
	counter.QueryStepCount(NSDate.FromTimeIntervalSinceNow(-8 * 60 * 60), NSDate.Now, NSOperationQueue.CurrentQueue, StepQueryHandler);
    }

    void StepQueryHandler(int nssteps, NSError error)
    {
        Console.WriteLine(nssteps);
    }

Powered by WordPress