Cordova-plugin

I fail to use cordova-plugin-dbmeter in my project. The documentation says:
npm install cordova-plugin-name
npx cap sync
so far so good

And then?
What kind of documentation is this. How can you use the plugin then in your project?

I found the documentation of the plugin. But how do you get it in your project. With capacitor-plugins there are things like: import { Geolocation } from ‘@capacitor/geolocation’; Then you can use the plugin. How do you get the methods from a cordova-plugin ready to use in the code. It doesn’t help me if the documentation stops with: npm install/npx cap sync.

Not sure what documentation you are referring to, but it looks like it is documented on the plugin’s repo - GitHub - akofman/cordova-plugin-dbmeter: 🎤📣 Cordova plugin to get decibels from the microphone.

Please note that Cordova is not Capacitor though Capacitor supports using most Cordova plugins.

In Capacitor you use the Cordova plugins the same way you would use them in Cordova.

Your problem is you are using Typescript and you don’t know how to use javascript objects/plugins without Typescript types. That’s not related to Capacitor, you could be using Cordova with Typescript and having the same problem.

There is a project that have Typescript wrappers for a lot of Cordova plugins called awesome-cordova-plugins, that would allow you to use plugins with the import syntax

But it doesn’t have a wrapper for the dbmeter.

What you can do is to declare the plugin variable so Typescript doesn’t complain when you use it, in example for the dbmeter plugin, it should be something like declare var DBMeter: any;, since according to the plugin docs, it exposes a DBMeter global javascript object.

1 Like