UNPKG

3.2 kBTypeScriptView Raw
1import { IonicNativePlugin } from '@ionic-native/core';
2export interface BarcodeScannerOptions {
3 /**
4 * Prefer front camera. Supported on iOS and Android.
5 */
6 preferFrontCamera?: boolean;
7 /**
8 * Show flip camera button. Supported on iOS and Android.
9 */
10 showFlipCameraButton?: boolean;
11 /**
12 * Show torch button. Supported on iOS and Android.
13 */
14 showTorchButton?: boolean;
15 /**
16 * Disable animations. Supported on iOS only.
17 */
18 disableAnimations?: boolean;
19 /**
20 * Disable success beep. Supported on iOS only.
21 */
22 disableSuccessBeep?: boolean;
23 /**
24 * Prompt text. Supported on Android only.
25 */
26 prompt?: string;
27 /**
28 * Formats separated by commas. Defaults to all formats except `PDF_417` and `RSS_EXPANDED`.
29 */
30 formats?: string;
31 /**
32 * Orientation. Supported on Android only. Can be set to `portrait` or `landscape`. Defaults to none so the user can rotate the phone and pick an orientation.
33 */
34 orientation?: string;
35 /**
36 * Launch with the torch switched on (if available). Supported on Android only.
37 */
38 torchOn?: boolean;
39 /**
40 * Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.
41 */
42 resultDisplayDuration?: number;
43}
44export interface BarcodeScanResult {
45 format: 'QR_CODE' | 'DATA_MATRIX' | 'UPC_E' | 'UPC_A' | 'EAN_8' | 'EAN_13' | 'CODE_128' | 'CODE_39' | 'CODE_93' | 'CODABAR' | 'ITF' | 'RSS14' | 'RSS_EXPANDED' | 'PDF_417' | 'AZTEC' | 'MSI';
46 cancelled: boolean;
47 text: string;
48}
49/**
50 * @name Barcode Scanner
51 * @description
52 * The Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
53 *
54 * Requires Cordova plugin: `phonegap-plugin-barcodescanner`. For more info, please see the [BarcodeScanner plugin docs](https://github.com/phonegap/phonegap-plugin-barcodescanner).
55 *
56 * @usage
57 * ```typescript
58 * import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
59 *
60 * constructor(private barcodeScanner: BarcodeScanner) { }
61 *
62 * ...
63 *
64 *
65 * this.barcodeScanner.scan().then(barcodeData => {
66 * console.log('Barcode data', barcodeData);
67 * }).catch(err => {
68 * console.log('Error', err);
69 * });
70 * ```
71 * @interfaces
72 * BarcodeScannerOptions
73 * BarcodeScanResult
74 */
75export declare class BarcodeScannerOriginal extends IonicNativePlugin {
76 Encode: {
77 TEXT_TYPE: string;
78 EMAIL_TYPE: string;
79 PHONE_TYPE: string;
80 SMS_TYPE: string;
81 };
82 /**
83 * Open the barcode scanner.
84 * @param {BarcodeScannerOptions} [options] Optional options to pass to the scanner
85 * @returns {Promise<any>} Returns a Promise that resolves with scanner data, or rejects with an error.
86 */
87 scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult>;
88 /**
89 * Encodes data into a barcode.
90 * NOTE: not well supported on Android
91 * @param {string} type Type of encoding
92 * @param {any} data Data to encode
93 * @returns {Promise<any>}
94 */
95 encode(type: string, data: any): Promise<any>;
96}
97
98export declare const BarcodeScanner: BarcodeScannerOriginal;
\No newline at end of file