I need to create and install a custom, cordova plugin into a cordova-based Windows 8 phone app. At present, the button click handler in the app cannot see the js object which makes the call to cordova.exec
That object, with the function that calls cordova.exe is called dlScanner It has a function, scanBarcode which calls cordova.exec
The click handler is this:
$(document).ready(function () {
$('#cmdOne').click(function () {
dlScanner.scanBarcode(
function (results) {
alert(results);
}), function (err) {
alert(err);
}, 'lowercaseworld'
});
});
The error message is this:
TypeError: Cannot read property 'scanBarcode' of undefined
Context: I used the Microsoft plugin generator, PluginGenerator, found here. Then I used the View Designer, on the app's config.xml file, in Visual Studio Community 2015, to install that plugin into the generic cordova Windows 8 phone app which VS had created for me earlier.
That plugin install process put this in the app's config.xml file
<vs:plugin name="com.contoso.dlScanner" version="0.1.0" src="C:\Users\TestAndDemo\dlScanner" />
In the dlScanner directory (referenced above) there are src and www directories and a plugin.xml file
In that plugin.xml file is this:
<js-module src="www/dlScanner.js" name="dlScanner">
<clobbers target="dlScanner" />
</js-module>
<!-- wp8 -->
<platform name="wp8">
<config-file target="config.xml" parent="/*">
<feature name="dlScanner">
<param name="wp-package" value="dlScanner"/>
</feature>
</config-file>
<source-file src="src/wp/dlScanner.cs" />
The www/dlScanner.js file contains this:
var dlScanner = {
scanBarcode: function (successCallback, errorCallback, strInput) {
cordova.exec(successCallback, errorCallback, "dlScanner", "scanBarcode", [strInput]);
}
}
module.exports = dlScanner;
What do I have to do to enable the click handler to see the dlScanner object?
Thanks
cordova.define('cordova/plugin_list', function(require, exports, module) { module.exports = [
my BlankApp that VS created does not have that. So I think I either need that file or I need to make my www/dlScanner.js file run. Both domodule.exports
Ideas? – Bimonthly