简体   繁体   中英

ZXing Barcode Scanner for Webapps

I'm trying to use http://zxing.appspot.com/scan to call Barcode Scanner from a WebApp, but I can't get it to work. Even after needlessly updating and reinstalling it, all it does is show the default zxing webpage that asks me to install Barcode Scanner on my phone. Am I missing something?

Here's the javascript I'm using to call ZXing Scanner. For test purposes, I've even tried to make a simple HTML hyperlink, without success. I'm using Android's WebView to load the app.

window.location.href = 
"http://zxing.appspot.com/scan?ret=http://192.168.1.33:3000/pallet/{CODE}/change_position/"+positionId+"&SCAN_FORMATS=CODE_39";

And this is the Barcode Scanner's manifest that identifies and triggers the scanner through browser:

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:scheme="http" android:host="zxing.appspot.com" android:path="/scan"/>
</intent-filter>

Funny thing is, http://www.google.com/m/products/scan , that does the same thing, works perfectly. Any help or idea is very welcome! Thanks a lot!

看起来您正在向本地网络上的图像(192.168 ... IP地址)发送URL,zxing.appspot.com将无法通过Internet访问。

是的触发它是这样的:

zxing://scan/?ret=http://192.168.2.9/stock/add.php?barcode={CODE}

I think I gave some thoughts on the project mailing list, but had another bright idea:

Are you sure you haven't 'saved' your preference for handling this link in the browser? For example when you have a choice of app you're typically asked whether you want to use that app forever to open that kind of link or Intent. Maybe you did that for this link only, and Browser. Go to Applications and "Clear defaults" for all these apps and try again.

它适用于我的默认Android浏览器,但不适用于Google Chrome浏览器

Just to share my input using this from HTML anchor element inside Angular 2+ app:

  1. ret part of the link needs to be urlencoded so just use

  this.callbackUrl = encodeURIComponent(`${currentURL}{CODE}&SCAN_FORMATS=Code 39`); this.totalBarCodeUrl = `http://zxing.appspot.com/scan?ret=${this.callbackUrl}`; 

  1. HTML be like:

  <a [href]="totalBarCodeUrl"></a> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM