KaFu61
April 6, 2018, 1:23pm
1
Hey,
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
AND
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?
KaFu61
April 6, 2018, 2:10pm
3
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: [
StatusBar,
SplashScreen,
Gyroscope,
DeviceMotion,
GesturesService,
HTTP,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
...
using it in my custom GesturesService like this:
this.platform.ready().then((readyState) => {
let options: GyroscopeOptions = {
frequency: 1000
};
this.gyroscope.getCurrent()
.then((orientation: GyroscopeOrientation) => {
console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
});
this.devMotion.getCurrentAcceleration().then(
(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
System:
Node : v6.11.4
npm : 3.10.10
OS : Windows 10
Environment Variables:
ANDROID_HOME : not set
Misc:
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.
KaFu61
April 6, 2018, 4:21pm
5
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.
KaFu61
April 7, 2018, 12:27pm
8
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 )