API initialization logic of SAP Cordova

Time:2022-5-19

sap. ndc. Barcodescannerbutton: button control used to start the barcode scanning process (display barcode icon). If the local scanning function is not available or the camera function is not granted, the button is either hidden or provides backup by opening a dialog box with input fields, in which the barcode can be entered manually. After barcodescanner is loaded, executeinitmethod:

API initialization logic of SAP Cordova

    //    * Feature vector (sap.Settings.isFeatureEnabled) is available
    //  * Barcode scanner is enabled by the Feature Vector
    //  * Barcode scanner Cordova plug-in (cordova.plugins.barcodeScanner) or zxing-js (ZXing.BrowserMultiFormatReader) is available

The available attribute defaults to true:
API initialization logic of SAP Cordova

native device capabilities should be by default enabled if there is no feature vector available to restrict the capability.

API initialization logic of SAP Cordova

Cordova API not detected in browser:
API initialization logic of SAP Cordova

API initialization logic of SAP Cordova

Then try to getZXingAPIThis is an asynchronous process.

API initialization logic of SAP Cordova

oZXingScannerAPIAvailable.
API initialization logic of SAP Cordova

After clicking the barcode button, execute the code in line 129 belowscanmethod.

If the barcode scanning function is not available, start the barcode scanning process, display the real-time input from the camera or display the dialog box to enter the value directly.

Barcode scanning is done asynchronously. When it is triggered, the function returns without waiting for the scan process to complete. The application must provide callback functions to respond to successful scans, errors during scans, and real-time input events on dialog boxes.

Fnsuccess passes an object with text, formatting, and cancellation properties. Text is the text representation of barcode data, format is the detected barcode type, and cancel is whether the user cancels scanning. Fnerror gives the error, and fnliveupdate is passed the new value entered in the input field of the dialog box.

API initialization logic of SAP Cordova

Only when cordovascanner API is available, the following branch of line 584 is entered:

API initialization logic of SAP Cordova

Otherwise, enter line 618 and a dialog box will pop up.

API initialization logic of SAP Cordova

SAP Fiori client is the native mobile application runtime container of SAP Fiori application. SAP Fiori client allows users to access their SAP Fiori applications online. Later, I will introduce how to solve the problem of unavailable Cordova plug-in in Fiori client.