I am just developing a sample Application to track user Activities with CMMotionActivityManager
like Running and walking etc.
I tested it with my iPad Mini, and its not working. Code I written was below,
if ([CMMotionActivityManager isActivityAvailable]) {
self.activityManager = [[CMMotionActivityManager alloc] init];
[self.activityManager startActivityUpdatesToQueue:[[NSOperationQueue alloc] init]
withHandler:
^(CMMotionActivity *activity) {
dispatch_async(dispatch_get_main_queue(), ^{
if ([activity stationary]) {
NSLog(@"Stationary");
}
else if ([activity walking]) {
NSLog(@"Walking");
}
else if ([activity running]) {
NSLog(@"Running");
}
else if ([activity automotive]) {
NSLog(@"Vehicle");
}
else if ([activity cycling]) {
NSLog(@"Cycling");
}
else {
NSLog(@"Unknown");
}
});
}];
}`
So was only some devices supports Activity Manager.If so what are them.
Of course I got the solution.
My iPAD mini does not have support for CMMotionActivityManager, I tested the same code with iPhone6 and iPhone6 Plus, it worked pretty good.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.