on 2018 Sep 26 7:28 PM
Hi I just developed a UI5 application (acceded through the Fiori LPD) that requires bar code scanning. For this I used a regular button:
<Button icon="sap-icon://bar-code" id="buttonScan" press="onPressScan" visible="{device>/system/phone}" />
And in the "press" action I used the code:
onPressScan: function (oEvent) {
sap.ndc.BarcodeScanner.scan(
function (mResult) {
if (!mResult.cancelled && mResult.text.length > 0) {//action}
},
function (sError) {//error handling},
function (mLive) {
if (mLive.newValue && mLive.newValue.length > 0) {//action}
}
);
}
It works nice using the SAP Fiori Client, accessing the device's camera after tapping over the scan button.
The thing is: The customer is using iPods with a barcode sleeve (I don't know which brand) and they want to capture the scanned value and pass it to the application without tapping the button.
Is it possible to implement something like a listener to catch the barcode sleeve scanned value into my app?
Regards,
Gregory Mayorga
Hi Gregory,
Short answer is yes, but you first need to know which sleeve model your customer is using because you need to get your hands on the right cordova plugin to connect to the sleeve hardware. For instance, one of our clients uses the Linea Pro and they provide an iOS cordova plugin. With that you will need to create a custom Fiori client and add the aforementioned plugin. The plugin API will most likely have a method to add a listener to the "scan" event where you can put your business logic. The logic to get it working once you have your custom Fiori client done is very simple, something like the code below. In this case, Infinea is the Javascript object that comes with the plugin for the Linea Pro
/**
* Default Infinea - Overwrite this method for other
*/
initialiseBarcodeScanner: function () {
if (window.Infinea) {
window.Infinea.init();
}
},
/**
* Default Infinea - Overwrite this method for other
*/
destroyBarcodeScanner: function () {
if (window.Infinea) {
window.Infinea.barcodeDataCallback = null;
}
},
/**
* Default Infinea - Overwrite this method for other
*/
addBarcodeHandler: function (fScanSuccess) {
if (window.Infinea) {
window.Infinea.barcodeDataCallback = function (sBarcode, sType, sTypeText) {
var oResult = {
text: sBarcode
};
fScanSuccess(oResult);
}.bind(this);
}
}
I hope this information helps,
Good luck,
Diego
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
My customer is using a Linea Pro sleeve scanner and I managed to solve this issue with something like the recommendation of diego.borja.
Regards,
Gregory Mayorga.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
13 | |
11 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.