javascript - Phonegap Barcodescanner won't start after function fired -
i've tried create simple app barcodescanner plugin seems won't fire after try make call.
phonegap build recognises plugin , app starts without problems, button won't fire scanning event. maybe barcodescanner might not start. aint quite @ point should have gotten error before starting app.
i've tried test app on both android , windows no result. i've tried use older build of phonegap no result. using 3.7 @ moment.
i've tried alternative approaches try , create /phonegap create projectname adding plugins platform etc. still same result.
my html , js
document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready() { function scan() { cordova.plugins.barcodescanner.scan( function (result) { alert("we got barcode\n" + "result: " + result.text + "\n" + "format: " + result.format + "\n" + "cancelled: " + result.cancelled); }, function (error) { alert("scanning failed: " + error); } ); } }
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <title>roargame</title> </head> <body> <button data-icon="search" onclick="scan()">scan me now!!!!</button> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8" src="barcodescanner.js"></script> <script type="text/javascript" charset="utf-8" src="js/app.js"></script> </body> </html>
my xml config
<?xml version='1.0' encoding='utf-8'?> <widget id="com.testdomain.barcode" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"> <name>roargame</name> <description> test barcodescanner </description> <author email="nota@mail.com" href="https://testdomain.com"> random name </author> <content src="index.html" /> <gap:plugin name="com.phonegap.plugins.barcodescanner" version="2.2.0" /> <icon src="icon.png" /> </widget>
check javascript console errors.
Comments
Post a Comment