当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Detect user arrived to a location and depart from a location pattern using CMMotionManager

问题描述:

I am working on app which requires to detect user arrived to place and depart from a place and time spent in that location.

I am reading CoreMotion Readings but unable to get any clue how to form patterns.

if (_motionManager == nil) {

_motionManager = [[CMMotionManager alloc]init];

}

_motionManager.deviceMotionUpdateInterval = 1/60;

[_motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {

if (error) {

[_motionManager stopDeviceMotionUpdates];

NSLog(@"Error while reading accelerometer data: %@", error.description);

return;

}

[self getacceleration:motion];

}];

In filterMotionData I am trying to read device acceleration with motion.userAcceleration but not find any good solution.

- (void)getacceleration:(CMMotion*)motion {

CMAcceleration acceleration = motion.userAcceleration;

//Calculate Device acceleration

}

Here If I can calculate device acceleration then on slowing down device acceleration I can say user arrived to a Location and when as device acceleration increased for particular time period means user depart from a location.

I was exploring I came to know Moves app does the same for all version of devices.

I gone through CLVisit API provided by CLLocationManager but it won't give short stay of user in a location and also its notify very late.

Please guide if anyone work on same type of requirement.

分享给朋友:
您可能感兴趣的文章:
随机阅读: