The mfilechooser plugin to work for my cordova based app on the android emulator or device. No errors are reported but the chooser is not launching.
Here is the snippet of my code.
index.js
function choose(){
window.plugins.mfilechooser.open([], function (uri) {
alert(uri);
}, function (error) {
alert(error);
});
}
function onDeviceReady() {
}
function domLoaded(){
document.addEventListener("deviceready", onDeviceReady, false);
}
index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy"
default-src 'self';
connect-src *;
style-src 'self' data: chrome-extension-resource: 'unsafe-inline';
img-src 'self' data: chrome-extension-resource:;
frame-src 'self' data: chrome-extension-resource:;
font-src 'self' data: chrome-extension-resource:;
media-src *;>
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>Hello World</title>
</head>
<body onload="domLoaded()">
<div>
<h1>Apache Cordova</h1>
</div>
<div>
<button onClick="choose()">choose file</button>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
Cordova 6.3.1 file chooser : https://github.com/MaginSoft/MFileChooser
Thanks for your help
Your CSP probably don't allow you to run inline javascript, so the onclick is not doing anything.
Try adding this in your Content-Security-Policy
meta tag
script-src 'unsafe-inline';