cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

I’m using the sap.ndc.BarcodeScannerButton for the barcode scanning. It is working fine on the fiori client.

But I want to hide the button if scanning is not possible (like on a desktop browser). I set therefore the property provideFallback to false, but the button is still visible. When I click on the button then the fallback popup appears and says that the scanner is not available. How can I hide the button if scanning is not possible?

<ndc:BarcodeScannerButton scanSuccess="onScanSuccess" provideFallback="false" />

I tested also the sap.ndc.BarcodeScanner.getStatusModel method. It returns always available = true.

I have additional an issue with the cancelation of the scanning. If the user cancels the scanning then also the fallback popup appears where the user can enter the value manual. Is it possible to skip this popup?

0 Likes
View Entire Topic
Former Member
0 Likes

You can create a JSON model with device information like this

var oModel = new JSONModel(Device); 

oModel.setDefaultBindingMode("OneWay");

this.setModel(oModel, "device");

and than in your XML you can hide the button if

{device>/system/desktop}

frankmueller9
Participant
0 Likes

Hi Emanuele,

thank you very much for your replay.

I know that I can check the device type. But I also must distinguish between the fiori client and the browser on the phone / tablet. I hopped that this API will check this.

Is there another way to check if the fiori client (cordova) or the kapsel plugin is running?

Best regards

Frank

Former Member
0 Likes

Maybe I don't get it. Do you want to hide that button if you're on a desktop device right? So why would it matter if you're on your Fiori app or on a kapsel/hybrid app? You just want to hide it if you're not on a mobile device.

frankmueller9
Participant
0 Likes

The button uses the cordova barcode scanner. This one is only available in the fiori client app. It is not available in the browser. So if the user calls the app in a browser on the phone then the scanner is not working. That's why I'd like to hide this button there as well.

Former Member
0 Likes

Got it. So I think that the only thing you can do is to have two different apps, one deployed with cordova lib that shows the button and another one that is not embedding cordova and so does not have the button.

I don't think you can handle it in another way.

Are you using WebIDE to deploy this application?

frankmueller9
Participant
0 Likes

We are using WebIDE to deploy the app. But our app is very complex. It has 48 views. The effort to maintain 2 apps is not in the relation to hide a button. If I don't find another solution then I will hide the button based on the the device type. So if a user calls the app on the phone browser then he will see the fallback popup.

Former Member
0 Likes

I've never tested it because right now I've no time to setup this kind of example but what you could do is this.

On the startup of your app, print in a dialog the JSON of the Device object (what I've showed to you in the comment) and compare that info between the version embedded in the app and the one opened by the browser on the phone.

Than you should check if you have some value to play with to show/hide the button.