Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Unifying API for BlackBerry10
Browse files Browse the repository at this point in the history
  • Loading branch information
timwindsor committed Jul 15, 2015
1 parent 8cf9df1 commit 02c5ba8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
8 changes: 2 additions & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -350,21 +350,17 @@

<!-- BlackBerry 10 -->
<platform name="blackberry10">
<js-module src="www/blackberry10/client.js" name="BarcodeScanner">
<clobbers target="cordova.plugins.barcodeScanner" />
</js-module>

<source-file src="src/blackberry10/index.js" target-dir="BarcodeScanner" />
<lib-file src="src/blackberry10/native/device/libBarcodeScanner.so" arch="device"/>
<lib-file src="src/blackberry10/native/simulator/libBarcodeScanner.so" arch="simulator"/>
<config-file target="www/config.xml" parent="/widget">
<feature name="BarcodeScanner">
<param name="blackberry-package" value="com.blackberry.community.barcodescanner" />
<param name="blackberry-package" value="phonegap-plugin-barcodescanner" />
</feature>
</config-file>
<config-file target="www/config.xml" parent="/widget/rim:permissions">
<rim:permit>use_camera</rim:permit>
</config-file>
<dependency id="com.blackberry.app" />
<dependency id="cordova-plugin-bb-app" />
</platform>
</plugin>
20 changes: 13 additions & 7 deletions src/blackberry10/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var barcodescanner,
module.exports = {

// methods to start and stop scanning
startRead: function (success, fail, args, env) {
scan: function (success, fail, args, env) {
var result = new PluginResult(args, env);
resultObjs[result.callbackId] = result;
readCallback = result.callbackId;
Expand Down Expand Up @@ -102,17 +102,23 @@ JNEXT.BarcodeScanner = function () {
for(i=3; i<arData.length; i++) {
data += " " + arData[i];
}
}
}

if (events.indexOf(receivedEvent) != -1) {
console.log(callbackId);
console.log(data);
if (receivedEvent == "community.barcodescanner.codefound.native") {
this.stopRead(callbackId);
result.callbackOk(data, true);

}
if(receivedEvent == "community.barcodescanner.ended.native") {
if (receivedEvent == "community.barcodescanner.started.native") {
console.log("Scanning started successfully");
}
if (receivedEvent == "community.barcodescanner.errorfound.native") {
result.callbackError(data, false);
}

if(receivedEvent == "community.barcodescanner.ended.native" || receivedEvent == "community.barcodescanner.errorfound.native") {
delete resultObjs[readCallback];
readCallback = null
readCallback = null;
}

};
Expand Down

0 comments on commit 02c5ba8

Please sign in to comment.