Gyroscope
Read Gyroscope sensor data
Repo: https://github.com/NeoLSN/cordova-plugin-gyroscope
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-gyroscope $ npm install --save @ionic-native/gyroscope@4 - Add this plugin to your app's module
 
Supported platforms
- Android
 - iOS
 
Usage
import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope';
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);
   });
Instance Members
watch(options)
Watching for gyroscope sensor changes
| Param | Type | Details | 
|---|---|---|
| options | 
      GyroscopeOptions
     | 
    
       Optional  | 
  
  Returns: Observable<GyroscopeOrientation> Returns an Observable that resolves GyroscopeOrientation
getCurrent(options)
Get current data from gyroscope sensor
| Param | Type | Details | 
|---|---|---|
| options | 
      GyroscopeOptions
     | 
    
       Optional  | 
  
  Returns: Promise<GyroscopeOrientation> Returns a promise that resolves GyroscopeOrientation
GyroscopeOrientation
| Param | Type | Details | 
|---|---|---|
| x | 
      number
     | 
    
       Represent x-axis  | 
  
| y | 
      number
     | 
    
       Represent y-axis  | 
  
| z | 
      number
     | 
    
       Represent z-axis  | 
  
| timestamp | 
      number
     | 
    
       Represent timestamp of sensor read. Default is 10000ms  | 
  
GyroscopeOptions
| Param | Type | Details | 
|---|---|---|
| frequency | 
      number
     | 
    
       Represent how often (in milliseconds) sensor should be read. Default is 10000 ms  |