close
close

javascript – Open barcode scanner app from webpage on IOS devices

javascript – Open barcode scanner app from webpage on IOS devices

I have a web page, on Android devices when you press a button you have the option to read a barcode using an app and then the reading result is sent back to the web page.

For example on Android this application works very well to read barcodes: https://play.google.com/store/apps/details?id=com.teacapps.barcodescanner&hl=en_US

Java Script Code

        function redirect_to_scanner() {
            let current_url = window.location.href.split('?')(0);
            let new_url = "zxing://scan/?ret=" + encodeURIComponent(current_url + "?barcode={CODE}");
            window.location.href = new_url;
        }

This code works perfectly on Android devices but not on iOS devices, in this case a message appears “An error has occurred, unable to open the application”

Is there another URI I can use that works on iOS devices? or a way to make it work on iOS devices?

The other option would be to open a barcode reader inside the webpage written in java script like quagga js but I would like to avoid this option as it doesn’t work very well for reading 20 digit barcodes. Any recommendation?