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