IOS版添加phonegap--二維碼掃描插件教程

1.下載插件BarcodeScanner。


2.拷貝 .h,.cpp and .mm scannerOverlay.xib 文件到 Plugins文件夾下面。


3.把barcodescanner.js文件放到你的www包裏面,引入barcodescanner.js到你的html頁面。


4.在你的config.xml 配置文件裏面添加插件。
key: org.apache.cordova.barcodeScanner
value: CDVBarcodeScanner


5.爲你的項目引入庫文件。
a.AVFoundation.framework
b.AssetsLibrary.framework
c.CoreVideo.framework
D.libiconv.dylib
點擊你的項目 target ,而後再Build Phases選項裏面, 找到Link Binary ,再下面有個加號點擊後,在裏面選擇庫文件就能夠了。


6.在你的html代碼裏面加入該方法:
window.plugins.barcodeScanner.scan(
function(result) {
if (result.cancelled)
alert("the user cancelled the scan")
Else
alert("we got a barcode: " + result.text)
},
function(error) {
alert("scanning failed: " + error)
}

)


執行該方法後就會打開攝像頭,掃描二維碼就能識別出二維碼信息。


KeyMob移動廣告平臺是國內專業的移動廣告 、優化管理平臺,爲廣告主和應用開發者提供最優的廣告產品服務, 創造最高的收入。

html

相關文章
相關標籤/搜索