2014-03-14 27 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

相关问题