NOTICE - This question was originally posted before Apple introduced motion-detection hardware and associated APIs in the iOS SDK. Answers to this question, however, remain relevant.
I'm creating an iPhone iOS app which involves tracking a user's running and / or walking. It is very important that the recorded results of the users runs and walks remain honest. I need a way to catch a user who may be cheating (or accidentally have left the tracker on) when using a car.
To check if the user is driving or riding in a car I first thought of these two checks, however neither can really determine if the user is in a car or not (to a point).
Check the user's current speed in the following method. If the user is traveling faster than 20-ish MPH, then I could assume that the user is in a car:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { CLLocation *recentLocation = [locations lastObject]; recentLocation.speed; //If speed is over 20 MPH, assume the user is not on their feet.
However, I'm not sure if this is really a good check because people have been recorded to go faster than that before. Is this a good check or should I use something else?
Determine how fast the user is accelerating using the Accelerometer and Motion APIs provided with the Core Motion Framework. If the user accelerates over a certain rate, then I could assume the user is traveling in a vehicle.
Are these assumptions correct? I guess my real question is this: Is there any better way to detect if the user is moving in a vehicle - if so how?. And if not, then are these checks suitable for this case or would this just be annoying to some users who are actually that fast? Is CoreMotion the proper API to do this with?
EDIT: The new iPhones 5S M7 Coprocessor provides more accurate movement detection. Could anyone explain how to use the new M7 APIs?
Aucun commentaire:
Enregistrer un commentaire