Search code examples
ionic-frameworkionic6

Ionic 6 Cannot find any gyroscope mention at all


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?


Solution

  • 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)