IOS - How to find out if a device is up / down (CoreMotion)

How can I tell using CoreMotion if an iOS device has been lifted or reset? (for example, there is one of them in one "trembling"). Displacement does not matter (in this case it will be less than 50 centimeters).

And will it work on all devices? (the reasons why this did not work may be hardware related)

Thanks for the help!

+3
ios objective-c cocoa-touch core-motion movement
source share
2 answers

This question has already appeared.

In short, you will need userAcceleration . Check its component in the x, y, and z directions. If the z component is significant, but x and y are not, your phone will accelerate vertically (rises / drops).

If you want to detect vibrations, look at sudden changes in user acceleration. You can use a high pass filter for this.

+1
source share

The accelerometer shows the force of gravity, which applies to the x / y / z axes. Theoretically, the total force (x^2 + y^2 + z^2) is 1 when the device is in standby mode. And, theoretically, it will drop to 0 when the device is on the fly.

I have not tested this in practice, however :)

0
source share

All Articles