# cordova-plugin-zebra-scanner
**Repository Path**: xfworld/cordova-plugin-zebra-scanner
## Basic Information
- **Project Name**: cordova-plugin-zebra-scanner
- **Description**: zebra scanner cordova plugin
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2020-05-11
- **Last Updated**: 2021-03-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
> cordova-zebra-scanner plugin: https://gitee.com/xfworld/cordova-plugin-zebra-scanner
> Cordova plugin for zebra barcode reader using [emdk] https://techdocs.zebra.com/emdk-for-android/7-6/tutorial/tutBasicScanningAPI/
## 目前主要支持版本
SDK 来源于 zebra 官网
- zebra TC200J - Android 7.1.2
## Supported Platforms
- Android
## Installation
### With cordova
```bash
cordova plugin add https://gitee.com/xfworld/cordova-plugin-zebra-scanner.git
```
### With ionic
```
ionic cordova plugin add https://gitee.com/xfworld/cordova-plugin-zebra-scanner.git
```
## Usage
最简单的用法如下:
### Enable listener
```js
window.plugins.zebra.nativeListen(
data => {
console.info("Scanned: " + data);
},
error => {
console.error("Error occured: " + error);
}
);
```
### Disable listener
```js
window.plugins.zebra.release();
```
### enable readings from within your application
js function define
```js
scanPressed () {
this.window.plugins.zebra.softwareTriggerStart(function(data) {
console.log('Software scan: ' + data);
}, function(error) {
console.log('Error occured: ' + error);
});
}
scanReleased () {
this.window.plugins.zebra.softwareTriggerStop();
}
```
and html invoker
```html
```
This module instantiate the emdk manager during the init phase of the plugin
### claim
Claim the access of the device
For optimization, please call this function during apps resume event
```js
window.plugins.zebra.claim(() => console.info('claim success'), (err) => console.info(err));
```
### release
Release the current connected device if exist.
For optimization, please call this function during apps pause event
```js
window.plugins.zebra.release(() => console.info('release success'), (err) => console.info(err));
```
### register
Bind the device callback event. Each call of the register function will remove the old callback
```js
window.plugins.zebra.register((event) => {
if (event.success) console.info(`new data from barcode device : ${event.data}`);
else console.info('scan triggered but no data');
}, (err) => console.info(err));
```
### unregister
Unbind the current callback function returned by register function
```js
window.plugins.zebra.unregister(() => console.info('unregister done'));
```
### enableTrigger
Enable the trigger button. The trigger button is enable by default
```js
window.plugins.zebra.enableTrigger(() => console.info('trigger enabled'));
```
### disableTrigger
Disable the trigger button.
```js
window.plugins.zebra.disableTrigger(() => console.info('trigger disabled'));
```