Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ Use this plugin when you want a ready-to-use scanning modal without building a c

<docgen-index>

- [`present(...)`](#present)
- [`addListener('CodeScannerCatchEvent', ...)`](#addlistenercodescannercatchevent-)
- [Interfaces](#interfaces)
- [Type Aliases](#type-aliases)
* [`present(...)`](#present)
* [`addListener('CodeScannerCatchEvent', ...)`](#addlistenercodescannercatchevent-)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)

</docgen-index>

Expand All @@ -111,7 +111,8 @@ present(scannerOption: ScannerOption) => Promise<void>
| ------------------- | ------------------------------------------------------- |
| **`scannerOption`** | <code><a href="#scanneroption">ScannerOption</a></code> |

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


### addListener('CodeScannerCatchEvent', ...)

Expand All @@ -126,36 +127,38 @@ addListener(eventName: 'CodeScannerCatchEvent', listenerFunc: (event: { code: st

**Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>

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


### Interfaces


#### ScannerOption

| Prop | Type | Description |
| ----------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| **`detectionWidth`** | <code>number</code> | Width of the detection area relative to the available width (0–1). Default is 0.4. |
| **`detectionHeight`** | <code>number</code> | Height of the detection area relative to the detection width. Default is 1 on iOS and 0.15–0.2 is typical on Android. |
| **`detectionHeight`** | <code>number</code> | Height of the detection area relative to the detection width. Default is 1 on iOS; 0.15–0.2 is typical on Android. |
| **`enableCloseButton`** | <code>boolean</code> | Enable close button on the top left of the scanning area (default: true) |
| **`sheetScreenRatio`** | <code>number</code> | Specify the ratio of the scanning area (sheet modal size) to the screen size. Default is 0.9 for android, 1(pageSheet) for iOS. |
| **`CodeTypes`** | <code>MetadataObjectTypes[]</code> | Specify the types of codes to recognize (default: ["qr", "code39", "ean13"]) |
| **`isMulti`** | <code>boolean</code> | Enable multi scan mode (default: false) |
| **`enableAutoLight`** | <code>boolean</code> | Enable auto light when environment is dark (default: true) |


#### PluginListenerHandle

| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |


### Type Aliases


#### MetadataObjectTypes

<code>
'aztec' | 'code128' | 'code39' | 'code39Mod43' | 'code93' | 'dataMatrix' | 'ean13' | 'ean8' | 'face' |
'interleaved2of5' | 'itf14' | 'pdf417' | 'qr' | 'upce' | 'catBody' | 'dogBody' | 'humanBody' | 'salientObject'
</code>
<code>'aztec' | 'code128' | 'code39' | 'code39Mod43' | 'code93' | 'dataMatrix' | 'ean13' | 'ean8' | 'face' | 'interleaved2of5' | 'itf14' | 'pdf417' | 'qr' | 'upce' | 'catBody' | 'dogBody' | 'humanBody' | 'salientObject'</code>

</docgen-api>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class CodeScannerPlugin : Plugin() {
return
}

val codeTypes = call.getArray("CodeTypes", JSArray.from(arrayOf("qr", "code39", "ean13")))!!;
val codeTypes = call.getArray("CodeTypes")
?: call.getArray("metadataObjectTypes")
?: JSArray.from(arrayOf("qr", "code39", "ean13"))
val detectionWidth: Float = call.getFloat("detectionWidth") ?: 0.4f
val detectionHeight: Float = call.getFloat("detectionHeight") ?: 1f

Expand Down
6 changes: 2 additions & 4 deletions docs/code-scanner.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const scanQRCode = async () => {
detectionWidth: 0.6,
detectionHeight: 0.15,
isMulti: false,
CodeTypes: ['qr'],
});
};

Expand All @@ -28,16 +29,13 @@ const scanMultipleCodes = async () => {
detectionWidth: 0.8,
detectionHeight: 0.2,
isMulti: true,
CodeTypes: ['qr', 'code39', 'ean13', 'code128'],
});
};
```

`isMulti: true` keeps the modal open so you can scan many codes. Option fields are on the [API](/docs/api#scanneroption) page.

> **Known limitation in v8.0.3:** the public TypeScript interface exposes `metadataObjectTypes`,
> but the native implementations still read the legacy `CodeTypes` key. Because the legacy key is
> not part of `ScannerOption`, omit code-type filtering with this release.

## addListener

```typescript
Expand Down
4 changes: 3 additions & 1 deletion ios/Sources/CodeScannerPlugin/CodeScannerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ public class CodeScannerPlugin: CAPPlugin, AVCaptureMetadataOutputObjectsDelegat
metadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)

// コードの認識を設定
let ObjectTypes = call.getArray("CodeTypes", String.self) ?? ["qr", "code39", "ean13"]
let ObjectTypes = call.getArray("CodeTypes", String.self)
?? call.getArray("metadataObjectTypes", String.self)
?? ["qr", "code39", "ean13"]
var metadataObjectTypes = [AVMetadataObject.ObjectType]()

for type in ObjectTypes {
Expand Down
13 changes: 11 additions & 2 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ export type MetadataObjectTypes =
| 'salientObject';

export interface ScannerOption {
/**
* Width of the detection area relative to the available width (0–1).
* Default is 0.4.
*/
detectionWidth?: number;

/**
* Height of the detection area relative to the detection width.
* Default is 1 on iOS; 0.15–0.2 is typical on Android.
*/
detectionHeight?: number;

/**
Expand All @@ -46,12 +55,12 @@ export interface ScannerOption {
/**
* Specify the types of codes to recognize (default: ["qr", "code39", "ean13"])
*/
metadataObjectTypes?: MetadataObjectTypes[];
CodeTypes?: MetadataObjectTypes[];

/**
* Enable multi scan mode (default: false)
*/
isMulti: boolean;
isMulti?: boolean;

/**
* Enable auto light when environment is dark (default: true)
Expand Down