How to judge intensity of shaking in android phones

Hi everyone. I am building a game and I need to know how fast a user is shaking his or her phone. The faster they shake the more points they will collect. Is there any special piece of code that would tell me this in Unity?

Thanking you in advance.

Check the acceleration of the device, check how long before the polarity changes and that tells you how hard the guy is shaking.

  1. Get acceleration axis
  2. Is it different from previous
  3. if no increase a counter return method
  4. if yes, check counter value
  5. if value too big shaking is too slow, counter to 0
  6. if value small enough increase shakeValue, counter to 0
  7. at the end of process if shakeValue is big enough, you won

Actually, step 8 may be discarded, considering that if the shaking becomes too low during the process then you put shakingValue down to 0. It would be a design decision.