Created
May 23, 2017 08:52
-
-
Save notflip/7254d52ab172b33d6ede1ba4987f98a9 to your computer and use it in GitHub Desktop.
Phonegap Barcode Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<widget xmlns = "http://www.w3.org/ns/widgets" | |
xmlns:gap = "http://phonegap.com/ns/1.0" | |
id = "com.phonegap.example" | |
versionCode = "10" | |
version = "1.0.0" > | |
<name>Phonegap Barcodescanner</name> | |
<description>Barcodescanner voorbeeld</description> | |
<author href="https://notflip.be" email="miguel@notflip.be">Miguel Stevens</author> | |
<platform name="ios"/> | |
<platform name="android"/> | |
<platform name="winphone"/> | |
<!-- enkel standaard voorkeuren, meer in de docs --> | |
<preference name="phonegap-version" value="cli-6.5.0" /> | |
<preference name="orientation" value="portrait" /> | |
<preference name="fullscreen" value="false" /> | |
<preference name="webviewbounce" value="false" /> | |
<preference name="DisallowOverscroll" value="true" /> | |
<preference name="disallowOverscroll" value="true" /> | |
<preference name="target-device" value="universal"/> | |
<preference name="deployment-target" value="7.0"/> | |
<preference name="exit-on-suspend" value="false"/> | |
<preference name="detect-data-types" value="true"/> | |
<preference name="prerendered-icon" value="false"/> | |
<preference name="StatusBarOverlaysWebView" value="false" /> | |
<preference name="ios-statusbarstyle" value="default"/> | |
<preference name="StatusBarStyle" value="default" /> | |
<preference name="android-minSdkVersion" value="21" /> | |
<preference name="android-installLocation" value="auto" /> | |
<!-- Plugins --> | |
<plugin name="cordova-plugin-barcodescanner" /> | |
<preference name="permissions" value="none"/> | |
<access origin="*" subdomains="true"/> | |
<allow-intent href="http://*/*"/> | |
<allow-intent href="https://*/*"/> | |
<allow-intent href="tel:*"/> | |
<allow-intent href="sms:*"/> | |
<allow-intent href="mailto:*"/> | |
<allow-intent href="geo:*"/> | |
<platform name="android"> | |
<allow-intent href="market:*"/> | |
</platform> | |
<platform name="ios"> | |
<allow-intent href="itms:*"/> | |
<allow-intent href="itms-apps:*"/> | |
</platform> | |
</widget> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Phonegap Build QR</title> | |
<script src="phonegap.js"></script> | |
</head> | |
<body> | |
<button id="scan">Scan</button> | |
<script src="js/jquery.min.js"></script> | |
<script> | |
// Onclick roep de scan functie aan. | |
$('button#scan').click(function() { | |
scan(); | |
}); | |
function scan() { | |
// de cordova.plugins zijn functies die native apparaat aanroepen. | |
cordova.plugins.barcodeScanner.scan( | |
function (result) { | |
// result.text is de waarde van de barcode die gescanned is. | |
// result.format is het type barcode (niet belangrijk) | |
// result.cancelled zal op true staan als je de scan afbreekt door terug te keren. | |
alert("We got a barcode\n" + | |
"Result: " + result.text + "\n" + | |
"Format: " + result.format + "\n" + | |
"Cancelled: " + result.cancelled); | |
}, | |
// als er een error is kan je deze hier opvangen. | |
function (error) { | |
alert("Scanning failed: " + error); | |
}, | |
{ | |
// enkele default opties. volledige lijst kan je in de docs van de plugin vinden | |
showFlipCameraButton : true, | |
orientation : "portrait", | |
disableAnimations : true, | |
disableSuccessBeep: false | |
} | |
); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment