2016-07-08 06:36:10 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
2016-02-02 22:35:45 +08:00
|
|
|
|
|
|
|
/**
|
2016-03-14 03:45:07 +08:00
|
|
|
* @name Barcode Scanner
|
2016-02-23 05:20:00 +08:00
|
|
|
* @description
|
2016-02-02 22:35:45 +08:00
|
|
|
* The Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
|
|
|
|
*
|
2016-02-08 06:12:13 +08:00
|
|
|
* Requires Cordova plugin: `phonegap-plugin-barcodescanner`. For more info, please see the [BarcodeScanner plugin docs](https://github.com/phonegap/phonegap-plugin-barcodescanner).
|
2016-02-02 22:35:45 +08:00
|
|
|
*
|
|
|
|
* @usage
|
2016-07-20 23:17:09 +08:00
|
|
|
* ```typescript
|
|
|
|
* import { BarcodeScanner } from 'ionic-native';
|
2016-03-25 01:00:18 +08:00
|
|
|
*
|
|
|
|
*
|
2016-02-08 06:12:13 +08:00
|
|
|
* BarcodeScanner.scan().then((barcodeData) => {
|
2016-02-02 22:35:45 +08:00
|
|
|
* // Success! Barcode data is here
|
|
|
|
* }, (err) => {
|
|
|
|
* // An error occurred
|
|
|
|
* });
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
plugin: 'phonegap-plugin-barcodescanner',
|
2016-02-23 05:20:00 +08:00
|
|
|
pluginRef: 'cordova.plugins.barcodeScanner',
|
2016-03-15 01:38:35 +08:00
|
|
|
repo: 'https://github.com/phonegap/phonegap-plugin-barcodescanner',
|
2016-04-30 11:56:49 +08:00
|
|
|
platforms: ['Android', 'iOS', 'Windows Phone 8', 'Windows 10', 'Windows 8', 'BlackBerry 10', 'Browser']
|
2016-02-02 22:35:45 +08:00
|
|
|
})
|
|
|
|
export class BarcodeScanner {
|
2016-02-08 06:12:13 +08:00
|
|
|
|
2016-07-06 02:52:21 +08:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
2016-06-11 22:56:30 +08:00
|
|
|
static Encode: any = {
|
|
|
|
TEXT_TYPE: 'TEXT_TYPE',
|
|
|
|
EMAIL_TYPE: 'EMAIL_TYPE',
|
|
|
|
PHONE_TYPE: 'PHONE_TYPE',
|
|
|
|
SMS_TYPE: 'SMS_TYPE'
|
|
|
|
};
|
2016-02-08 06:12:13 +08:00
|
|
|
/**
|
|
|
|
* Open the barcode scanner.
|
2016-08-17 19:28:21 +08:00
|
|
|
* @param options {Object} Optional options to pass to the scanner
|
2016-02-15 22:59:44 +08:00
|
|
|
* @return Returns a Promise that resolves with scanner data, or rejects with an error.
|
2016-02-08 06:12:13 +08:00
|
|
|
*/
|
2016-06-14 04:44:11 +08:00
|
|
|
@Cordova({
|
|
|
|
callbackOrder: 'reverse'
|
|
|
|
})
|
2016-06-09 21:38:58 +08:00
|
|
|
static scan(options?: any): Promise<any> { return; }
|
2016-02-08 06:12:13 +08:00
|
|
|
|
2016-06-11 22:56:30 +08:00
|
|
|
/**
|
|
|
|
* Encodes data into a barcode.
|
|
|
|
* NOTE: not well supported on Android
|
2016-08-17 19:28:21 +08:00
|
|
|
* @param type {string} Type of encoding
|
|
|
|
* @param data {any} Data to encode
|
2016-06-11 22:56:30 +08:00
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-07-08 06:36:10 +08:00
|
|
|
static encode(type: string, data: any): Promise<any> { return; }
|
2016-06-11 22:56:30 +08:00
|
|
|
|
2016-02-02 22:35:45 +08:00
|
|
|
}
|