1

I have just installed and created a blank project on Ionic 6 / Angular.

Next I want to try the gyroscope.

Looking at the documentation the latest I can find the gyroscope is in ionic 4:

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

I tried the above and it won't install.

So, how do I use the gyroscope on Ionic 6 or has it been removed?

deszok
  • 145
  • 2
  • 14

1 Answers1

2

For Ionic 6, we use Capacitor to communicate with native components. For this one, you'll be able to find on Motion Capacitor API, where you can use RotationRate (alpha, beta and gamma which measures the amount of rotation around the z,x,y axis respectively) and Acceleration (x,y,z which measures the amount of acceleration along the x,y,z axis respectively)

José Lourenço
  • 129
  • 3
  • 4
  • hi José Lourenço, any idea if we can also get the magnetometter values via Motion API ? – MR.GEWA May 24 '23 at 22:02
  • Hello, @MR.GEWA . It seems like you can't get this data. But there's actually another package (I hope it's still working) here: https://www.npmjs.com/package/@ionic-native/magnetometer . This page doesn't actually count with some tutorial but you can check on the repository here: https://github.com/sdesalas/cordova-plugin-magnetometer . Hope it works for you ^ ^ – José Lourenço May 25 '23 at 16:29