Leonardo Leonardo - 2 years ago 105
iOS Question

Detect if device is moving iOS

Fact: iOS has a way to detect acceleration. But if a user opens my app while in movement and stays moving at the same speed, is there a way to "figure this out" without using the GPS?

I'm asking this because:

  • My app is very much likely to be used on places where the GPS signal is quite inaccurate, like basements and similar places

  • and most importantly: I don't care where the user is, all I want to know is if the user is moving or not...

PS: by moving I mean walking down the hall or crossing a street... you know, considerable movements (30 ft or more)... I could very well disregard short movements (couch to bathroom sort of thing, less than 30 ft...)

Ben Ben
Answer Source

The accelerometer works much like its name would suggest. It detects acceleration. So if you go from 0 mph to 5 mph it will notice that, but then if you continue at 5 mph for a while it won't detect anything (because there is no acceleration). You can try to combine this with the gyro which will detect rotational acceleration, but there is no technical way for the device to detect motion at a constant speed... so you will be able to detect any changes in motion, but if the user is going at a continuous pace you cannot detect that

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download