@ionic-native/gyroscope not working


i’m getting some different errors by trying to use the gyroscope-plugin:

  • if executing the gyroscope.watch() function like the ionic-native docs suggested, the error is “plugin-not-installed” but plugin installation was successful
  • if executing gyroscope.getCurrent() function like in the docs suggested, gyroscope is undefined.

Reinstalling the plugin and using the functions in platform.ready did not help.

Some Info about ionic version etc:
ionic 3.1.8
cordova 7.1.0
node 6.11.4

Need the plugin working for an educational project in my master of computer and media science.

Thanks in advance

How are you testing?
How did you install and integrate the plugin?
What is your ionic info output?

i am testing with ionic dev app (cordova is also available)
i have installed it like suggested in the docs:

$ ionic cordova plugin add cordova-plugin-gyroscope
$ npm install --save @ionic-native/gyroscope

integrated in app.module.ts providers

import { Gyroscope, GyroscopeOptions, GyroscopeOrientation } from '@ionic-native/gyroscope';
    providers: [
		{provide: ErrorHandler, useClass: IonicErrorHandler}

using it in my custom GesturesService like this:

this.platform.ready().then((readyState) => {
    let options: GyroscopeOptions = {
	 frequency: 1000

	.then((orientation: GyroscopeOrientation) => {
		console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);

	(acceleration: DeviceMotionAccelerationData) => console.log(acceleration),
	(error: any) => console.log(error)

did the same with device motion plugin and this works perfectly…

ionic info output:

cli packages:
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:
cordova (Cordova CLI) : 7.1.0

local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2

Node : v6.11.4
npm : 3.10.10
OS : Windows 10

Environment Variables:
ANDROID_HOME : not set

backend : pro

Ionic Dev app only supports a limited number of plugins: https://ionicframework.com/docs/pro/view.html#plugin-support The one you want to use seems to be not one of the supported ones.

thanks for the answer, but the same error occures when i build and run the app (testing on android)

do you have some other ideas?

Are you sure the device has a gyroscope? I have seen Android devices without one.

Yes i am very sure…

Could get it to work… seems like the installation with the node-package has a problem.
Downloaded the plugin directly from github solves the problem.

(cordova plugin add https://github.com/NeoLSN/cordova-plugin-gyroscope.git)