npm package: @scr2em/capacitor-scanner
Description: scan codes
Author: Mohamed M. Abdelgwad
Latest version: 6.0.34

# Capacitor Scanner

scan codes

## Install

```bash
npm install capacitor-scanner
npx cap sync
```

## API

<docgen-index>

* [`start(...)`](#start)
* [`stop()`](#stop)
* [`openSettings()`](#opensettings)
* [`capturePhoto(...)`](#capturephoto)
* [`checkPermissions()`](#checkpermissions)
* [`requestPermissions()`](#requestpermissions)
* [`flipCamera()`](#flipcamera)
* [`toggleFlash()`](#toggleflash)
* [`addListener('barcodeScanned', ...)`](#addlistenerbarcodescanned-)
* [`addListener('rectangleDetected', ...)`](#addlistenerrectangledetected-)
* [`removeAllListeners()`](#removealllisteners)
* [`enableObjectDetection(...)`](#enableobjectdetection)
* [`disableObjectDetection()`](#disableobjectdetection)
* [`enableBarcodeDetection(...)`](#enablebarcodedetection)
* [`disableBarcodeDetection()`](#disablebarcodedetection)
* [`zoom(...)`](#zoom)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### start(...)

```typescript
start(options?: StartOptions | undefined) => any
```

Start the camera preview with optional barcode and object detection.

| Param         | Type                                                  | Description                                          |
| ------------- | ----------------------------------------------------- | ---------------------------------------------------- |
| **`options`** | <code><a href="#startoptions">StartOptions</a></code> | - Configuration options for the camera and detection |

**Returns:** <code>any</code>

--------------------


### stop()

```typescript
stop() => any
```

Stop the camera preview and all detection.

**Returns:** <code>any</code>

--------------------


### openSettings()

```typescript
openSettings() => any
```

**Returns:** <code>any</code>

--------------------


### capturePhoto(...)

```typescript
capturePhoto(options?: CapturePhotoOptions | undefined) => any
```

| Param         | Type                                                                |
| ------------- | ------------------------------------------------------------------- |
| **`options`** | <code><a href="#capturephotooptions">CapturePhotoOptions</a></code> |

**Returns:** <code>any</code>

--------------------


### checkPermissions()

```typescript
checkPermissions() => any
```

**Returns:** <code>any</code>

--------------------


### requestPermissions()

```typescript
requestPermissions() => any
```

**Returns:** <code>any</code>

--------------------


### flipCamera()

```typescript
flipCamera() => any
```

**Returns:** <code>any</code>

--------------------


### toggleFlash()

```typescript
toggleFlash() => any
```

**Returns:** <code>any</code>

--------------------


### addListener('barcodeScanned', ...)

```typescript
addListener(event: 'barcodeScanned', listenerFunc: (result: BarcodeScannedEvent) => void) => any
```

| Param              | Type                                                                                     |
| ------------------ | ---------------------------------------------------------------------------------------- |
| **`event`**        | <code>'barcodeScanned'</code>                                                            |
| **`listenerFunc`** | <code>(result: <a href="#barcodescannedevent">BarcodeScannedEvent</a>) =&gt; void</code> |

**Returns:** <code>any</code>

--------------------


### addListener('rectangleDetected', ...)

```typescript
addListener(event: 'rectangleDetected', listenerFunc: (result: RectangleDetectedEvent) => void) => any
```

| Param              | Type                                                                                           |
| ------------------ | ---------------------------------------------------------------------------------------------- |
| **`event`**        | <code>'rectangleDetected'</code>                                                               |
| **`listenerFunc`** | <code>(result: <a href="#rectangledetectedevent">RectangleDetectedEvent</a>) =&gt; void</code> |

**Returns:** <code>any</code>

--------------------


### removeAllListeners()

```typescript
removeAllListeners() => any
```

**Returns:** <code>any</code>

--------------------


### enableObjectDetection(...)

```typescript
enableObjectDetection(options?: ObjectDetectionOptions | undefined) => any
```

Enable object detection (business card). This will start detecting business cards.

| Param         | Type                                                                      | Description                                   |
| ------------- | ------------------------------------------------------------------------- | --------------------------------------------- |
| **`options`** | <code><a href="#objectdetectionoptions">ObjectDetectionOptions</a></code> | - Optional configuration for object detection |

**Returns:** <code>any</code>

--------------------


### disableObjectDetection()

```typescript
disableObjectDetection() => any
```

Disable object detection. This will stop detecting business cards.

**Returns:** <code>any</code>

--------------------


### enableBarcodeDetection(...)

```typescript
enableBarcodeDetection(options?: BarcodeDetectionOptions | undefined) => any
```

Enable barcode detection. This will start detecting barcodes.

| Param         | Type                                                                        | Description                                    |
| ------------- | --------------------------------------------------------------------------- | ---------------------------------------------- |
| **`options`** | <code><a href="#barcodedetectionoptions">BarcodeDetectionOptions</a></code> | - Optional configuration for barcode detection |

**Returns:** <code>any</code>

--------------------


### disableBarcodeDetection()

```typescript
disableBarcodeDetection() => any
```

Disable barcode detection. This will stop detecting barcodes and clear cached barcodes.

**Returns:** <code>any</code>

--------------------


### zoom(...)

```typescript
zoom(options: ZoomOptions) => any
```

Set the camera zoom level.

| Param         | Type                                                | Description                                          |
| ------------- | --------------------------------------------------- | ---------------------------------------------------- |
| **`options`** | <code><a href="#zoomoptions">ZoomOptions</a></code> | - The zoom options containing the level (1, 2, or 3) |

**Returns:** <code>any</code>

--------------------


### Type Aliases


#### StartOptions

<code>{ /** * Barcode formats to detect when barcodeDetection is enabled. */ formats?: BarcodeFormat[]; /** * Camera direction to use. Defaults to 'BACK'. */ cameraDirection?: 'BACK' | 'FRONT'; /** * Enable barcode detection on start. Defaults to false. * When enabled, the camera will automatically detect barcodes and emit 'barcodeScanned' events. */ barcodeDetection?: boolean; /** * Whether to show the highlight overlay for detected barcodes. Defaults to false. * Only applies when barcodeDetection is true. */ barcodeHighlight?: boolean; /** * Enable object detection (business card) on start. Defaults to false. * When enabled, the camera will automatically detect business cards and emit 'rectangleDetected' events. */ objectDetection?: boolean; /** * Whether to show the highlight overlay for detected business cards. Defaults to true. * Only applies when objectDetection is true. */ objectHighlight?: boolean; /** * Minimum interval in seconds between consecutive 'rectangleDetected' events. * Only applies when objectDetection is true. * Defaults to 0 (no throttling beyond initial stability check). */ rectangleEmitIntervalSeconds?: number; /** * Optional regex pattern to filter scanned barcodes. * If provided, only barcodes matching this pattern will be reported. */ regex?: string; /** * Optional regex flags (e.g., 'i' for case-insensitive, 'm' for multiline). */ regexFlags?: string; /** * Cooldown in seconds after any detection event when both barcode and object detection are enabled. * After a barcode or rectangle is emitted, ALL detection pauses for this duration. * When set, barcode dedup TTL becomes 2x this value and rectangle emit interval becomes 2x this value. * Only applies when both barcodeDetection and objectDetection are true. * Defaults to 0 (no throttle, both detections run simultaneously). */ detectionThrottleSeconds?: number; }</code>


#### CapturePhotoOptions

<code>{ /** * The desired quality of the captured image, expressed as a value between 0.0 (lowest quality, smallest file size) * and 1.0 (highest quality, largest file size). Defaults to 1.0. * This parameter directly influences the compression level of the resulting JPEG image. */ qualityRatio?: number; }</code>


#### CapturePhotoResult

<code>{ imageBase64: string }</code>


#### PermissionsResult

<code>{ camera: 'prompt' | 'denied' | 'granted' }</code>


#### FlashResult

<code>{ enabled: boolean }</code>


#### BarcodeScannedEvent

<code>{ scannedCode: string; format: string }</code>


#### RectangleDetectedEvent

<code>{ detected: true }</code>


#### ObjectDetectionOptions

<code>{ /** * Whether to show the highlight overlay for detected business cards. * Defaults to true. */ showHighlight?: boolean, /** * Minimum interval in seconds between consecutive 'rectangleDetected' events. * After an event is emitted, no new events will be emitted until this interval passes. * Set to 0 to emit events as soon as stability is detected. * Defaults to 0 (no throttling beyond initial stability check). */ emitIntervalSeconds?: number }</code>


#### BarcodeDetectionOptions

<code>{ /** * Whether to show the highlight overlay for detected barcodes. * Defaults to false. */ showHighlight?: boolean; }</code>


#### ZoomOptions

<code>{ /** * The zoom level to set. Must be 1, 2, or 3. * - 1 = 1.0x (no zoom) * - 2 = 2.0x * - 3 = 3.0x */ level: 1 | 2 | 3; }</code>


#### ZoomResult

<code>{ level: number }</code>


### Enums


#### BarcodeFormat

| Members          | Value                      |
| ---------------- | -------------------------- |
| **`Aztec`**      | <code>'AZTEC'</code>       |
| **`Code39`**     | <code>'CODE_39'</code>     |
| **`Code93`**     | <code>'CODE_93'</code>     |
| **`Code128`**    | <code>'CODE_128'</code>    |
| **`DataMatrix`** | <code>'DATA_MATRIX'</code> |
| **`Ean8`**       | <code>'EAN_8'</code>       |
| **`Ean13`**      | <code>'EAN_13'</code>      |
| **`Itf14`**      | <code>'ITF14'</code>       |
| **`Pdf417`**     | <code>'PDF_417'</code>     |
| **`QrCode`**     | <code>'QR_CODE'</code>     |
| **`UpcE`**       | <code>'UPC_E'</code>       |

</docgen-api>