ReferenceError: "cordova is not defined" on imported Cordova Plugin.

Hi,
I imported the cordova-plugin-qrcodejs from GitHub via the Git Repo. Then, I made it available for my app. Lastly, I created a JS (and service) with the provided code.

Unfortunately, I can't make the plugin work. I adapted the code to mimic the JS from the Barcodescanner plugin, but I am getting error "ReferenceError: cordova is not defined" in the console.

Could you tell me how to define cordova or what I need to add to the JS so the plugin can work properly?

The JS code I have so far is below:

--------------------------------------------------------
define(['require', 'lodash'],

function (require, _) {

return [{
type: 'service',
name: 'QRCodeJS',
deps: ['Apperyio', encode]
}];

function encode(Apperyio) {

return function(config) {
serviceSettings = Apperyio.EntityAPI("QRCodeJS");
//var QRvalue = request.get('QRvalue');

var options = {
width: 256,
height: 256,
colorDark: "#000000",
colorLight: "#ffffff",
};
cordova.plugins.qrcodejs.encode('TEXT_TYPE', 'myemail@mydomain.me', function(base64EncodedQRImage) {
console.info('QRCodeJS response is ' + base64EncodedQRImage);
//TODO: use your base64EncodedQRImage
}, function(err) {
console.error('QRCodeJS error is ' + JSON.stringify(err));
}, options);
};
}
});
------------------------------------------

Thanks.
1 person has
this question
+1
Reply