Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
I came across sap.ndc.BarcodeScanner class. Below function can be used to open iOS device camera to scan the barcode.
	onPress: function(oEvent) {
sap.ndc.BarcodeScanner.scan(
function(mResult) {
alert("We got a bar code\n" +
"Result: " + mResult.text + "\n" +
"Format: " + mResult.format + "\n" +
"Cancelled: " + mResult.cancelled);
},
function(Error) {
alert("Scanning failed: " + Error);
},
);
}

 

Below are few steps to be able to use the iOS device camera by using above function.

  1. Create a new project by using ‘SAPUI5 Application’ template from WebIDE.

  2. Add a button into App.view.xml by using this code.
    <Button text="Scan" press="onPress" icon="sap-icon://bar-code"/>




  1. Open App.controller.js and import "sap/ndc/BarcodeScanner".

  2. Copy above function and paste it into App.controller.js.

  3. Deploy app to SAP Cloud Platform.

  4. Register app to the SAP Fiori Launchpad.

  5. Download SAP Fiori Client app into iOS device from App store.

  6. Copy Fiori Launchpad url and paste it into Fiori Client app.

  7. Open the app and try out the barcode scanning functionality.


In simple words, to use Barcode or QR code functionality, Fiori Launch pad must be running through SAP Fiori Client iOS app instead of an iOS device browser.

For more information please review this: https://sapui5.hana.ondemand.com/#/api/sap.ndc.BarcodeScanner.

 

References:

https://sapui5.hana.ondemand.com/#/api/sap.ndc.BarcodeScanner.
18 Comments
Labels in this area