How to detect device shake?

#1

I am struggling to figure out how to have my device detect shaking with expo. I see there’s an existing project called react-native-shake-event, but it seems to only work if I detach from expo. Is there an existing way of detecting shake events with expo?

0 Likes

#2

Hi! I think this could be done fairly easily using Expo’s gyroscope API, but I’m not sure if there’s an off-the-shelf library that will just handle it for you.

You could check for a feature request on Canny and create one there if it doesn’t already exist.

1 Like

#3

Ok I see. Was hoping for an off-the-shelf solution. I’ll use the accelerometer/gyroscope in Expo’s API to write my own. Thanks!

0 Likes

#4

hey did you find any off the shelf solution? @robotron

0 Likes

#5

No I never did. In the end it was pretty easy to create my own. I took a look at this stackoverflow post: https://stackoverflow.com/questions/2317428/android-i-want-to-shake-it

I modified one of the solutions I liked and reimplemented it using Expo’s accelerometer.

1 Like

#6

yeah it was pretty easy . already made one :stuck_out_tongue: in 10 minutes or so .

0 Likes