[expo-sensors] DeviceMotion / Gyroscope not working

Please provide the following:

  1. SDK Version: 42.0.0
  2. Platforms(Android/iOS/web/all): Android

Hi,

I’ve installed the expo-sensors package and tried to use both DeviceMotion and Gyroscope.

With both, I get isAvailable resolved to true by calling .isAvailableAsync, but the event listenter will never be triggered.

Example code (result ist the same for both DeviceMotion and Gyroscope). data will always stay null.

  const [data, setData] = useState(null)
  useEffect(() => {
    (async () => {
      const isAvailable = await DeviceMotion.isAvailableAsync()
      if(isAvailable) {
        const subscription = DeviceMotion.addListener((data) => {
          setData(data)
        })
        return subscription.remove()
      }
    })()
  }, [])

Thanks for your help,
Florian

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.