feat: Add enableCodeScanner to Expo Config Plugin

This commit is contained in:
Marc Rousavy
2023-10-05 11:06:38 +02:00
parent 6e249d165a
commit ffd64feee8
2 changed files with 67 additions and 2 deletions

View File

@@ -30,7 +30,18 @@ A Code Scanner is a separate Camera output (just like photo or video) that can d
On iOS, the Code Scanner uses the platform-native APIs and can be used out of the box.
On Android, the [MLKit Vision Barcode Scanning](https://developers.google.com/ml-kit/vision/barcode-scanning) API will be used, and the model (2.2MB) needs to be downloaded first. To download the model when the user installs your app, add this to your `AndroidManifest.xml` file:
On Android, the [MLKit Vision Barcode Scanning](https://developers.google.com/ml-kit/vision/barcode-scanning) API will be used, and the model (2.2MB) needs to be downloaded first.
<Tabs
groupId="environment"
defaultValue="rn"
values={[
{label: 'React Native', value: 'rn'},
{label: 'Expo', value: 'expo'}
]}>
<TabItem value="rn">
To download the model when the user installs your app, add this to your `AndroidManifest.xml` file:
```xml
<application ...>
@@ -41,6 +52,29 @@ On Android, the [MLKit Vision Barcode Scanning](https://developers.google.com/ml
</application>
```
</TabItem>
<TabItem value="expo">
To download the model when the user installs your app, add the `enableCodeScanner` flag to your Expo config (`app.json`, `app.config.json` or `app.config.js`):
```json
{
"name": "my app",
"plugins": [
[
"react-native-vision-camera",
{
// ...
"enableCodeScanner": true
}
]
]
}
```
</TabItem>
</Tabs>
## Usage
To use a codescanner, simply create a [`CodeScanner`](/docs/api/interfaces/CodeScanner) and pass it to the `<Camera>`: