This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo Gyroscope
A library that provides access to the device's gyroscope sensor.
Gyroscope from expo-sensors provides access to the device's gyroscope sensor to respond to changes in rotation in three-dimensional space.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
API
import { Gyroscope } from 'expo-sensors';
Classes
Type: Class extends DeviceSensor<GyroscopeMeasurement>
A base class for subscribable sensors. The events emitted by this class are measurements
specified by the parameter type Measurement.
Gyroscope Methods
Subscribe for updates to the gyroscope.
EventSubscriptionA subscription that you can call remove() on when you would like to unsubscribe the listener.
Checks user's permissions for accessing sensor.
Promise<PermissionResponse>Returns boolean which signifies if sensor has any listeners registered.
booleanYou should always check the sensor availability before attempting to use it.
Returns whether the gyroscope is enabled on the device.
On mobile web, you must first invoke Gyroscope.requestPermissionsAsync() in a user interaction (i.e. touch event) before you can use this module.
If the status is not equal to granted then you should inform the end user that they may have to open settings.
On web this starts a timer and waits to see if an event is fired. This should predict if the iOS device has the device orientation API disabled in
Settings > Safari > Motion & Orientation Access. Some devices will also not fire if the site isn't hosted with HTTPS as DeviceMotion is now considered a secure API.
There is no formal API for detecting the status of DeviceMotion so this API can sometimes be unreliable on web.
Promise<boolean>A promise that resolves to a boolean denoting the availability of the gyroscope.
Deprecated: use subscription.remove() instead.
voidAsks the user to grant permissions for accessing sensor.
Promise<PermissionResponse>Interfaces
A subscription object that allows to conveniently remove an event listener from the emitter.
Types
Each of these keys represents the rotation along that particular axis measured in radians per second (rad/s).
Literal type: union
Permission expiration time. Currently, all permissions are granted permanently.
Acceptable values are: 'never' | number