Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Migrate and upstream BarcodeScanner #386

Open
2 of 4 tasks
timwindsor opened this issue Jan 17, 2015 · 11 comments
Open
2 of 4 tasks

Migrate and upstream BarcodeScanner #386

timwindsor opened this issue Jan 17, 2015 · 11 comments

Comments

@timwindsor
Copy link
Collaborator

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

  • Need to migrate to use the same BarcodeScanner.js API as other platforms, with scan method
  • Drop stopRead method
  • Implement encode method (optional)
  • Build in a newer version of the ZXing library instead of the on-device version.
@timwindsor
Copy link
Collaborator Author

Upstream is here: phonegap/phonegap-plugin-barcodescanner#32

@scheideman
Copy link

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.

@timwindsor
Copy link
Collaborator Author

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.

@scheideman
Copy link

Okay so I am using https://github.com/davidshimjs/qrcodejs. But I am having a issue.
The steps I took are:

  1. I include the src file with a <source-file src="src/qrcode.js" /> tag in plugin.xml
  2. I used module.exports in qrcode.js to export the functions I need
  3. Get access to the module in index.js using:
    qr =require('plugin/com.blackberry.community.barcodescanner/qrcode.js');
  4. then call var qrcode = qr.<function name>(); to call the function from qrcode.js
  5. I call result.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?

@timwindsor
Copy link
Collaborator Author

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.

@scheideman
Copy link

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.

@scheideman
Copy link

Also what folder should the qrcode.js file go in? I have been placing it in the src folder with index.js.

@timwindsor
Copy link
Collaborator Author

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.

@scheideman
Copy link

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.

@scheideman
Copy link

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).

@timwindsor
Copy link
Collaborator Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants