Barcode scanning capabilities are integrated into our Profound UI Mobile Client; this is possible through the use of a Cordova barcode scanning plugin linked here.
If you are creating your own Apache Cordova app and are installing the plugins, please use the following links corresponding to the version of Cordova you are using:
- v5.0.0+ - Note: you will need to install this version from the repository as the suggested add code will install the latest version.
What the code is doing is defining a success and failure function that will be passed along to the scan function of the scanner object. These functions will fire depending on whether your barcode reader is successful in scanning a given barcode or not. Inside of these functions, we define the behavior we wish to occur depending on the context. For both of these functions, a parameter will be passed that gives the relevant info needed; in a success function, the object that is passed contains a "text" property that contains the value of the barcode scanner and a "format" property that contains the format type of the barcode scanned. In a failure function, the object passed is just a string containing the reason for the failure. You can see in the success function we are changing the value of the "code" textbox to be equal to the "text" property of the passed object called "result"; this changes the textbox's value to the scanned barcode's value. The if statement surrounding the scanner variable and scan call is checking to see if you are on mobile running Apache Cordova (which our client uses) first. If not it will automatically call the failure function (in this example nothing is passed into it, but you could pass it a string explaining that you are not on a mobile device), which simply throws an alert that displays the error.
Here is the code driving this screen:
The exit button is bound to the btnExit indicator, which ends the program. The save button has a "pui.click()" call in it's "onclick" property which submits the screen to the code.