2014-03-14 76 views
0

我們正在嘗試在我們的移動網絡應用中整合條形碼掃描器的phonegap插件。任何人都可以幫助我整合這個嗎?如何在移動web應用程序中爲條形碼掃描器集成Phonegap插件?

我說,Phonegap.js和cardova.js,插件嘗試安裝,但它需要太多的時間,而不是安裝..

這裏是我的HTML內容

<!DOCTYPE html> 
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta charset="utf-8" /> 
<title>Bar code Reader</title> 
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> 
<script src="barcodescanner.js"></script> 
<script src="cordova.js"></script> 
<script> 
$(document).ready(function() { 
app.initialize(); 
}); 
function clickScan() { 
console.log("I am now scanning"); 
window.plugins.barcodeScanner.scan(function (result) { 
alert("We got a barcode\n" + 
"Result: " + result.text + "\n" + 
"Format: " + result.format + "\n" + 
"Cancelled: " + result.cancelled); 
}, function (error) { 
alert("Scanning failed: " + error); 
}); 
} 
</script> 
</head> 
<body> 
<button id="scan" style="padding: 10px;" onclick="clickScan">Scan!</button> 
</body> 
</html> 
+0

鏈路github上用於條形碼掃描器的PhoneGap插件? –

回答

1

按照以下步驟

1.Download和命令提示安裝Node.js

2.run此命令$ sudo npm install -g phonegap

3.創建$ phonegap create hello com.example.hello HelloWorld

4.go到hello目錄$ cd hello

5.chose平臺命名爲你好的應用程序我顯示你的IOS你可以建立在Android系統過於

$ phonegap build ios 
[phonegap] detecting iOS SDK environment... 
[phonegap] using the local environment 
[phonegap] compiling iOS... 
[phonegap] successfully compiled iOS app 

6.您想添加的添加插件phonegap local plugin add https://github.com/phonegap-build/BarcodeScanner.git

7.要遠程編譯您的應用程序,請將b與所述另外的遠程命令uild命令:$ phonegap remote install ios # ...or... $ phonegap remote run ios

+0

你可以與我分享更多關於如何/我應該在哪裏添加這個細節? – Shashibhushan

0

這裏是條形碼掃描器的插件的使用的一個示例:

<!DOCTYPE HTML> 
<html> 
<head> 
    <title>Barcode Scanner DEMO</title> 

<script type="text/javascript" src="plugins/plugin-loader.js"></script> 
<script type="text/javascript" charset="utf-8"> 

monaca.viewport({width : 320}); 

function scanBarcode() { 
    window.plugins.barcodeScanner.scan(function(result) { 
      alert("We got a barcode\n" + 
        "Result: " + result.text + "\n" + 
        "Format: " + result.format + "\n" + 
        "Cancelled: " + result.cancelled); 
     }, function(error) { 
      alert("Scanning failed: " + error); 
     } 
); 

} 
</script> 
</head> 

<hr> BarcodeReader DEMO <hr><br> 
<input type="button" onClick ="scanBarcode()" value ="Scan" /> 
</body> 
</html> 
+0

希望你不是在談論混合應用程序。我可以看到Monaca適用於Hybrid應用程序。我需要在手機上插入我的網站(webapp)。 – Shashibhushan

相關問題