Open timwindsor opened 9 years ago
Upstream is here: https://github.com/phonegap/phonegap-plugin-barcodescanner/pull/32
Since the ZXing c++ port does not have the encoding methods implemented I looked at some JavaScript libraries as Tim suggested. Here are two that I found which look like they might work: https://github.com/davidshimjs/qrcodejs https://github.com/metafloor/bwip-js
The first one is more popular, much smaller and easier to integrate; however it only for making QRcodes.
From what I can tell, it appears that iOS does QRCode only, but Android can take extra parameters to do any supported pattern. We're probably fine just doing the QRCode only then.
Okay so I am using https://github.com/davidshimjs/qrcodejs. But I am having a issue. The steps I took are:
<source-file src="src/qrcode.js" />
tag in plugin.xmlmodule.exports
in qrcode.js to export the functions I need qr =require('plugin/com.blackberry.community.barcodescanner/qrcode.js');
qrcode = qr.<function name>();
to call the function from qrcode.jsresult.ok(data, false)
to return the encoded barcode img, However when I run the app and result.ok()
is called I get a undefined warning in frameworkModules.js at
define('lib/plugins/default.js', function (require, exports, module){
...
try {
requestObj.getExtension().getMethod().exec();
} catch (e) {
console.warn(e.msg);
<undefined warning>
fail(-1, e.msg, e.code);
}
};
And the data is not returned to client.js. Any suggestions?
If you open frameworkModules.js while this is added, do you see the qrcode module there? What is it called in the define("...") line?
Also, I expect I didn't mention this before, but you want to apply your work to the plugin in this repo: https://github.com/blackberry/phonegap-plugin-barcodescanner, not here, which is older code before we migrated it into the phonegap cross platform one.
Yes here is the define line:
define('plugin/com.blackberry.community.barcodescanner/qrcode.js', function (require, exports, module)
Oh okay, I will start working off that repo.
Also what folder should the qrcode.js file go in? I have been placing it in the src folder with index.js.
I think it should go in src with index.js - but I wonder what the right require() call is. It might actually be just:
require('qrcode');
You might have to mess around with it, or even trace the require call to find out.
I got it working. I have it set up so the encode method returns a 64 bit encoded png image. I just have to do some testing now.
The only thing I am not sure about is if there is any extra processing I need to do for the different data types (eg. TEXT_TYPE, EMAIL_TYPE, SMS_TYPE,PHONE_TYPE).
My thought is that those values are used by the Android ZXing encoder to tweak things. Maybe ignore it for now, unless you have time to test it on and Android device or simulator.
With version 2.0 of the BarcodeScanner, we can now better integrate with the PhoneGap plugin.
Destination repo is here: https://github.com/blackberry/BarcodeScanner
Source is here: https://github.com/blackberry/WebWorks-Community-APIs/tree/master/BB10-Cordova/BarcodeScanner
Planned upstream location is now: https://github.com/hypery2k/cordova-barcodescanner-plugin