Getting compass heading in ionic capacitor in 2023

I used to get the device compass heading using ionic-native/device-orientation. This won’t work any more because it’s too old and won’t compile.

I’ve tried the one from @awesome-cordova but I can’t get this to work - it gives a lot of errors.

The capacitor plugin ‘motion’ does not seen to have the actual device orientation only changes in it.

Are there any options or should I wait 6 months when a working plugin might be available?

1 Like

Same observation and same needs.

I use the Cordova plugin for the moment. It works fine with IOS devices and more or lass with some Android devices but it doesn’t work with some other Android devices such as Xiaomi.

It could be very nice to have a good native working tool (that does not need to ask the permissions to work if it is possible).


With the plugin @awesome-cordova-plugins/device-orientation, you can get the key trueHeading which is relative to the geographic North Pole in degrees.

It works fine but seems to be not up to date and so, it is not supported on the newest devices.