Property 'MediaScannerPlugin' does not exist on type 'CordovaPlugins'

545 Views Asked by At

l am trying to use Media Scanner Plugin . That Plugin is using to refreshing files folder after downloading . The problem is while i use this code below

    cordova.plugins.MediaScannerPlugin.scanFile(this.place + image);
 //This is the code line that you need.You need to use this line where your download thing  happens

i have error under MediaScannerPlugin

Property 'MediaScannerPlugin' does not exist on type 'CordovaPlugins'

Any idea please how to use this plugin ?

1

There are 1 best solutions below

7
OO7 On

I believe you have to add the plugin (using npmjs) before you can use it.

1) By using npmjs, change current directory to root cordova project.

2) Then you add the plugin to your project,

cordova plugin add cordova-plugin-mediascanner

3) To see if the plugin been installed succesfully in your project, you can type:

 cordova plugin

You can also verify package.json file (on base project directory), by checking the plugin on dependencies and cordova plugins specification.

4) When the plugin has js file for initialization or any certain function, then you must add the js script link (.js) into the index.html.

Example:

<script type="text/javascript" src="vendor/plugin-name/plugin-script.js"></script>

Hope this helps.