Skip to content

Instantly share code, notes, and snippets.

@erhanyasar
Last active March 9, 2023 14:00
Show Gist options
  • Save erhanyasar/5f9b00e8b0a1eebff01e1b29f761d10a to your computer and use it in GitHub Desktop.
Save erhanyasar/5f9b00e8b0a1eebff01e1b29f761d10a to your computer and use it in GitHub Desktop.
A sample integration to use related barcode applications in order to read QR data
function tryAppStore() {
setTimeout(function() {
window.location = "https://appsto.re/tr/6XPCz.i";
}, 25);
window.location="Barcode://scan/";
}
function tryGoogleStore() {
setTimeout(function() {
window.location = "https://play.google.com/store/apps/details?id=com.google.zxing.client.android&hl=en";
}, 25);
window.location="zxing://scan/?ret=http%3A%2F%2Ffoo.com%2Fproducts%2F%7BCODE%7D%2Fdescription&SCAN_FORMATS=UPC_A,EAN_13";
}
function GetURLParameter(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
return sParameterName[1];
}
}
if (window.navigator.userAgent.indexOf('iPhone') != -1)
tryAppStore();
else if (window.navigator.userAgent.indexOf('Android') != -1)
tryGoogleStore();
else
alert("Please use an iOS or Android OS!..");
var barcode = GetURLParameter('barcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment