Skip to main content

Gyroscope

Read Gyroscope sensor data

https://github.com/NeoLSN/cordova-plugin-gyroscope

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation#

$ npm install cordova-plugin-gyroscope
$ npm install @ionic-native/gyroscope
$ ionic cap sync

Supported Platforms#

  • Android
  • iOS

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope/ngx';
constructor(private gyroscope: Gyroscope) { }
...
let options: GyroscopeOptions = {
frequency: 1000
}
this.gyroscope.getCurrent(options)
.then((orientation: GyroscopeOrientation) => {
console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
})
.catch()
this.gyroscope.watch()
.subscribe((orientation: GyroscopeOrientation) => {
console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
});