@greenie2600 wrote:
I’m trying to integrate this plugin into my project. I installed it (per the instructions). I imported it into my
app.module.ts
, and added it to myproviders
array. And, I’m able to injectDeviceOrientation
into my page controller.Up to this point, everything works – at least, in the sense that I don’t get any errors. However, as soon as I try to use the plugin (i.e., by calling
this.deviceOrientation.getCurrentHeading()
orthis.deviceOrientation.watchHeading().subscribe()
), I get a console error. (I’m running my project in the Ionic DevApp on my Android phone.)[12:47:09] console.warn: Native: tried calling DeviceOrientation.getCurrentHeading, but the DeviceOrientation plugin is not installed. [12:47:09] console.warn: Install the DeviceOrientation plugin: 'ionic cordova plugin add cordova-plugin-device-orientation'
I’ve tried running the suggested
ionic cordova plugin add
command. It succeeds:Adding cordova-plugin-device-orientation to package.json Saved plugin info for "cordova-plugin-device-orientation" to config.xml
But, my app still produces the same error.
I tried uninstalling and reinstalling the plugin, with the same result.
Any ideas?
Also: the docs for this Cordova plugin say:
With the W3C Device Orientation API now being supported on iOS, Android and Windows devices, this plugin is not needed any more. Migrating from this plugin to the W3C Device Orientation API is explained in this PhoneGap blog post.
Is there an alternative service for Angular 4 that would be a suitable replacement for the DeviceOrientation plugin? I looked for one, but it’s a hard thing to Google. I know I could just roll my own using the browser’s native APIs – but it someone has already figured out the platform inconsistencies and a clean promise-based API, then I’d rather not reinvent the wheel.
Posts: 1
Participants: 1