{"_id":"@ahaselden/barcode-scanner","_rev":"4-1724d23fdf4b73ca27e50bfd8fd498ef","name":"@ahaselden/barcode-scanner","dist-tags":{"latest":"2.1.3"},"versions":{"2.1.1":{"name":"@ahaselden/barcode-scanner","version":"2.1.1","description":"A fast and efficient (QR) barcode scanner for Capacitor","main":"dist/plugin.js","module":"dist/esm/index.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","author":{"name":"tafelnl"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/THARUE/barcode-scanner.git"},"bugs":{"url":"https://github.com/THARUE/barcode-scanner/issues"},"keywords":["capacitor","plugin","native"],"scripts":{"docgen":"docgen --api BarcodeScannerPlugin --output-readme API_REFERENCE.md","lint":"npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint","eslint":"eslint . --ext ts","prettier":"prettier \"**/*.{css,html,ts,js,java}\"","swiftlint":"node-swiftlint","build":"npm run clean && tsc && rollup -c rollup.config.js","clean":"rimraf ./dist","watch":"tsc --watch","prepare":"npm run build","verify":"npm run verify:ios && npm run verify:android && npm run verify:web","verify:ios":"cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination \"platform=iOS Simulator,name=iPhone 12\" && cd ..","verify:android":"cd android && ./gradlew clean build test && cd ..","verify:web":"npm run build"},"devDependencies":{"@capacitor/android":"^3.0.0","@capacitor/core":"^3.0.0","@capacitor/docgen":"0.0.17","@capacitor/ios":"^3.0.0","@ionic/eslint-config":"^0.3.0","@ionic/prettier-config":"^1.0.1","@ionic/swiftlint-config":"^1.1.2","eslint":"^7.11.0","husky":"^4.3.0","prettier":"~2.2.0","prettier-plugin-java":"~1.0.0","pretty-quick":"^3.1.0","rimraf":"^3.0.2","rollup":"^2.32.0","swiftlint":"^1.0.1","typescript":"~4.0.3"},"peerDependencies":{"@capacitor/core":"^3.0.0"},"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"prettier":"@ionic/prettier-config","swiftlint":"@ionic/swiftlint-config","eslintConfig":{"extends":"@ionic/eslint-config/recommended"},"husky":{"hooks":{"pre-commit":"npx pretty-quick --staged"}},"homepage":"https://github.com/THARUE/barcode-scanner#readme","directories":{"example":"examples"},"dependencies":{},"gitHead":"de6939e9cc28f385370d5ddab9c39c31c3cfc411","_id":"@ahaselden/barcode-scanner@2.1.1","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-5nqoPGXianYtX2oajOF46T7z+xIqzxKsS6zG/8ai0HhfC1eABHlrx2zJPAXR3T0dev+vSxYC075snF+R2HHgHA==","shasum":"9b2705cb900980dd5c38bc845ac86d5e876e1f31","tarball":"https://registry.npmjs.org/@ahaselden/barcode-scanner/-/barcode-scanner-2.1.1.tgz","fileCount":28,"unpackedSize":91066,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFvcNTYPJQJOIozTN56VH86ES60h6ge1SRF/5TMsME/BAiEAiF3+luXPCQfyJy9EKI3jurdptkMbBs99DF/F7AqkvGA="}]},"_npmUser":{"name":"ahaselden","email":"andrewhaselden@gmail.com"},"maintainers":[{"name":"ahaselden","email":"andrewhaselden@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barcode-scanner_2.1.1_1633710523006_0.42370440575035295"},"_hasShrinkwrap":false},"2.1.2":{"name":"@ahaselden/barcode-scanner","version":"2.1.2","description":"A fast and efficient (QR) barcode scanner for Capacitor","main":"dist/plugin.js","module":"dist/esm/index.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","author":{"name":"tafelnl"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/THARUE/barcode-scanner.git"},"bugs":{"url":"https://github.com/THARUE/barcode-scanner/issues"},"keywords":["capacitor","plugin","native"],"scripts":{"docgen":"docgen --api BarcodeScannerPlugin --output-readme API_REFERENCE.md","lint":"npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint","eslint":"eslint . --ext ts","prettier":"prettier \"**/*.{css,html,ts,js,java}\"","swiftlint":"node-swiftlint","build":"npm run clean && tsc && rollup -c rollup.config.js","clean":"rimraf ./dist","watch":"tsc --watch","prepare":"npm run build","verify":"npm run verify:ios && npm run verify:android && npm run verify:web","verify:ios":"cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination \"platform=iOS Simulator,name=iPhone 12\" && cd ..","verify:android":"cd android && ./gradlew clean build test && cd ..","verify:web":"npm run build"},"devDependencies":{"@capacitor/android":"^3.0.0","@capacitor/core":"^3.0.0","@capacitor/docgen":"0.0.17","@capacitor/ios":"^3.0.0","@ionic/eslint-config":"^0.3.0","@ionic/prettier-config":"^1.0.1","@ionic/swiftlint-config":"^1.1.2","eslint":"^7.11.0","husky":"^4.3.0","prettier":"~2.2.0","prettier-plugin-java":"~1.0.0","pretty-quick":"^3.1.0","rimraf":"^3.0.2","rollup":"^2.32.0","swiftlint":"^1.0.1","typescript":"~4.0.3"},"peerDependencies":{"@capacitor/core":"^3.0.0"},"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"prettier":"@ionic/prettier-config","swiftlint":"@ionic/swiftlint-config","eslintConfig":{"extends":"@ionic/eslint-config/recommended"},"husky":{"hooks":{"pre-commit":"npx pretty-quick --staged"}},"homepage":"https://github.com/THARUE/barcode-scanner#readme","directories":{"example":"examples"},"dependencies":{},"gitHead":"b8efee706b25ba5d59d470c69fce911defb95590","_id":"@ahaselden/barcode-scanner@2.1.2","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-XZ5lqbZvjaoCyYXGxMfcE+QWfF+bUVjzrmD/N9ZsCB0d8q/iuyHrZ+u8tzRBIIlYGBc4+ZMI9hW9SB8B9MyaDQ==","shasum":"07abb3f3fb0bfb66d3a247373cf4babc0ff0afae","tarball":"https://registry.npmjs.org/@ahaselden/barcode-scanner/-/barcode-scanner-2.1.2.tgz","fileCount":30,"unpackedSize":98418,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhwwKQCRA9TVsSAnZWagAAD1AQAIAl3dxzXSPKANDWrxqi\ne+q1hjGdRcajerIVmjR34LuJHQk91tdq03jppxz3UaJ3DiYBqs+9tDGiJTQW\nFdQk0W+tUSwOl6rKHGewC2lwtpg+7d4+2Nu9gfbz1qAx4ulb25FTCM4nTYmR\nOSVlTOsIOqfMKIZRMM2BpJIbxkoSEbT6kaA0IqcrfYmM+gHUZ8CVw1MNvWrm\ntNmUkpUo4+p+bZN63gnavCzcZsvF8CgueMokLYWid5fsttbVauToJDCov2hh\nRqSphNAIbfCCVq7Dm4FMrPSo7lmrJmiyL5hEA3Ddz4B3B91JjXTaQ+MvIv7R\nyCiJEmUg2ePAUNY2ebOisB3kGGSYJnCDPxKrLUqOODX4ibyhJVh4FJ9XuL3b\nKIOhJTkLvoAOrF0zYzV9WtMFbY+nd25eBfNjwNx7m0C7tokCIN6MvwX78U3D\n9ASPFjJCDEmYsq/8YxiNquGkwpDMMw1evePZnDvP8lLmiKJctm3mwMCu6I+G\nil2bVXPyJeZKh6cQUzRXePwwcOi6pCNoXLHgJRygXCfZ78sLFLHm8T40Ulb3\nOnKmSuG/S1HDaHTDRvRfmjR1sz69UvUMqapqYpnSzeu9r+zoyHgDqiFuuB7L\ntd3T3k9qNHqoCsVGPcG8/f6Fawr008x4QuH6a7YBweF2r4txwC7otMwrVS6l\nSXys\r\n=5x4a\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCKh5TcQ/vLpWc8+uyI1tgtwCckQHkItoGzH1lXNbtbdQIgIl4VaATh/sJKf6zfeFqzSSk8WtRUy/R9XcDdrUca+YQ="}]},"_npmUser":{"name":"ahaselden","email":"andrewhaselden@gmail.com"},"maintainers":[{"name":"ahaselden","email":"andrewhaselden@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barcode-scanner_2.1.2_1633743084085_0.17408608066499864"},"_hasShrinkwrap":false},"2.1.3":{"name":"@ahaselden/barcode-scanner","version":"2.1.3","description":"A fast and efficient (QR) barcode scanner for Capacitor","main":"dist/plugin.js","module":"dist/esm/index.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","author":{"name":"tafelnl"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/THARUE/barcode-scanner.git"},"bugs":{"url":"https://github.com/THARUE/barcode-scanner/issues"},"keywords":["capacitor","plugin","native"],"scripts":{"docgen":"docgen --api BarcodeScannerPlugin --output-readme API_REFERENCE.md","lint":"npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint","eslint":"eslint . --ext ts","prettier":"prettier \"**/*.{css,html,ts,js,java}\"","swiftlint":"node-swiftlint","build":"npm run clean && tsc && rollup -c rollup.config.js","clean":"rimraf ./dist","watch":"tsc --watch","prepare":"npm run build","verify":"npm run verify:ios && npm run verify:android && npm run verify:web","verify:ios":"cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination \"platform=iOS Simulator,name=iPhone 12\" && cd ..","verify:android":"cd android && ./gradlew clean build test && cd ..","verify:web":"npm run build"},"devDependencies":{"@capacitor/android":"^3.0.0","@capacitor/core":"^3.0.0","@capacitor/docgen":"0.0.17","@capacitor/ios":"^3.0.0","@ionic/eslint-config":"^0.3.0","@ionic/prettier-config":"^1.0.1","@ionic/swiftlint-config":"^1.1.2","eslint":"^7.11.0","husky":"^4.3.0","prettier":"~2.2.0","prettier-plugin-java":"~1.0.0","pretty-quick":"^3.1.0","rimraf":"^3.0.2","rollup":"^2.32.0","swiftlint":"^1.0.1","typescript":"~4.0.3"},"peerDependencies":{"@capacitor/core":"^3.0.0"},"capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"prettier":"@ionic/prettier-config","swiftlint":"@ionic/swiftlint-config","eslintConfig":{"extends":"@ionic/eslint-config/recommended","ignorePatterns":["dist/**/*"]},"husky":{"hooks":{"pre-commit":"npx pretty-quick --staged"}},"homepage":"https://github.com/THARUE/barcode-scanner#readme","directories":{"example":"examples"},"dependencies":{},"gitHead":"57eafa34f148d2be9cba6d2e846ea2ced071dca9","_id":"@ahaselden/barcode-scanner@2.1.3","_nodeVersion":"14.15.1","_npmVersion":"8.7.0","dist":{"integrity":"sha512-zzaylvpQ6Fqy9umsvqI4W5h+UF8OB03ivN0/VjqyXyfV9cSOrSpiLRsq1BeCuGlCxpnkz+jOwNKhFOyN/vCXWw==","shasum":"bcc289b767a325088d5a99e69c615b13c279b91e","tarball":"https://registry.npmjs.org/@ahaselden/barcode-scanner/-/barcode-scanner-2.1.3.tgz","fileCount":30,"unpackedSize":116231,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDUlSIzIpK/9qBMMsq1CUPwqGUK3vo3xhRr/p9PAf7gbAiB3yat+JPXa80K+uvi3E/5asBLo+9kTaClrFpP0ph6EPQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiYmR7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqcDRAAosIy3Klm0hB/wTtuS6e7tiOWx1QgEAfTTgmFB2Rif+BXmMu6\r\nr5stRInquhExvaxZ2ZeDB8fKXpvuRdPSBt+2sadWVQ2Y/sJkS6naLp0Ici/V\r\nfN5ZF+BmmuxUESG/Fwdu/0UavRNJddhtDKIKcz/v+JrGGZAMiRDTO/BT79n6\r\nGef8U1Cw8L/uAga7Xw9o8TGbpYi7wyZIsJI5qHyNgDmZyozlTfX7tfLY1cSB\r\nOygP4rDEioPIFRx2YXKSYoeUgOQP+9vXc8yCwMlEL5TUW2yX9CM4IhrtioRF\r\n1tTieN1oGApKf7aRwNq4P9JjaouUdJDprCbDpAVCmNw4xHa/gjujKEF0rAmK\r\nzUweIdt9iDh+hXAZibGFekXCG9M2IspAKvzq0mEe03HbtEJCCK8shnomtXyF\r\nH6R8Xi8bSssM19OCEGO+Ln3SpWivb168fppU4RWwiUtpO6cF2D4TVhtffXdc\r\nQUv2VBR8Olu5HQOltGXjAyamIZjy4Y5MUyH28d7w+kDGyRbJA1+AdB13ufZM\r\nhcyFMhNtRjuycGrcboHPZ/T/SQKagKye1n3ZS2HT60QHV2I9n9kQ9VTMBVs0\r\nbW/v1t1eIqz5Ul50Wzr0lWjxLPu29WyWJ4tMVGZnO1Os7dDvIvwKOLp+og+V\r\n0C4sGoAa9q3XZ6vDlAgOul0k4XjHYBkJCMY=\r\n=hJEp\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"ahaselden","email":"andrewhaselden@gmail.com"},"maintainers":[{"name":"ahaselden","email":"andrewhaselden@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/barcode-scanner_2.1.3_1650615419793_0.319859967166942"},"_hasShrinkwrap":false}},"time":{"created":"2021-10-08T16:28:42.950Z","2.1.1":"2021-10-08T16:28:43.161Z","modified":"2022-04-22T08:17:00.037Z","2.1.2":"2021-10-09T01:31:24.246Z","2.1.3":"2022-04-22T08:16:59.936Z"},"maintainers":[{"name":"ahaselden","email":"andrewhaselden@gmail.com"}],"description":"A fast and efficient (QR) barcode scanner for Capacitor","homepage":"https://github.com/THARUE/barcode-scanner#readme","keywords":["capacitor","plugin","native"],"repository":{"type":"git","url":"git+https://github.com/THARUE/barcode-scanner.git"},"author":{"name":"tafelnl"},"bugs":{"url":"https://github.com/THARUE/barcode-scanner/issues"},"license":"MIT","readme":"<p align=\"center\"><br><img src=\"https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png\" width=\"128\" height=\"128\" /></p>\r\n<h3 align=\"center\">Barcode Scanner</h3>\r\n<p align=\"center\"><strong><code>@capacitor-community/barcode-scanner</code></strong></p>\r\n<p align=\"center\">\r\n  A fast and efficient (QR) barcode scanner for Capacitor.\r\n</p>\r\n\r\n<p align=\"center\">\r\n  <img src=\"https://img.shields.io/maintenance/yes/2022?style=flat-square\" />\r\n  <a href=\"https://www.npmjs.com/package/@capacitor-community/barcode-scanner\"><img src=\"https://img.shields.io/npm/l/@capacitor-community/barcode-scanner?style=flat-square\" /></a>\r\n<br>\r\n  <a href=\"https://www.npmjs.com/package/@capacitor-community/barcode-scanner\"><img src=\"https://img.shields.io/npm/dw/@capacitor-community/barcode-scanner?style=flat-square\" /></a>\r\n  <a href=\"https://www.npmjs.com/package/@capacitor-community/barcode-scanner\"><img src=\"https://img.shields.io/npm/v/@capacitor-community/barcode-scanner?style=flat-square\" /></a>\r\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\r\n<a href=\"#contributors-\"><img src=\"https://img.shields.io/badge/all%20contributors-1-orange?style=flat-square\" /></a>\r\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\r\n</p>\r\n\r\n## Table of Contents\r\n\r\n- [Maintainers](#maintainers)\r\n- [About](#about)\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n- [Troubleshooting](#troubleshooting)\r\n\r\n## Maintainers\r\n\r\n| Maintainer | GitHub                                | Active |\r\n| ---------- | ------------------------------------- | ------ |\r\n| thegnuu    | [thegnuu](https://github.com/thegnuu) | yes    |\r\n| tafelnl    | [tafelnl](https://github.com/tafelnl) | no     |\r\n\r\n## About\r\n\r\n### Supported barcodes\r\n\r\nOn **iOS** this library makes use of Apple's own `AVFoundation`. This means **[this list of barcodes](https://developer.apple.com/documentation/avfoundation/avmetadatamachinereadablecodeobject/machine-readable_object_types)** should be supported.\r\n\r\nOn **Android** this library uses [`zxing-android-embedded`](https://github.com/journeyapps/zxing-android-embedded) which uses [`zxing`](https://github.com/zxing/zxing) under the hood. That means **[this list of barcodes](https://github.com/zxing/zxing/#supported-formats)** is supported.\r\n\r\n### Note on supported Capacitor versions\r\n\r\n`v2.x` supports Capacitor `v3.x`\r\n\r\n`v1.x` supports Capacitor `v2.x`\r\n\r\nAll releases of this package can be found on [npm](https://www.npmjs.com/package/@capacitor-community/barcode-scanner?activeTab=versions) and on [GitHub Releases](https://github.com/capacitor-community/barcode-scanner/releases)\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @capacitor-community/barcode-scanner\r\nnpx cap sync\r\n```\r\n\r\n### iOS\r\n\r\nFor iOS you need to set a usage description in your info.plist file.\r\n\r\nThis can be done by either adding it to the Source Code directly or by using Xcode Property List inspector.\r\n\r\n**Adding it to the source code directly**\r\n\r\n1. Open up the Info.plist (in Xcode right-click > Open As > Source Code)\r\n2. With `<dict></dict>` change the following\r\n\r\n```diff\r\n<dict>\r\n+  <key>NSCameraUsageDescription</key>\r\n+  <string>To be able to scan barcodes</string>\r\n</dict>\r\n```\r\n\r\n_NOTE:_ \"To be able to scan barcodes\" can be substituted for anything you like.\r\n\r\n**Adding it by using Xcode Property List inspector**\r\n\r\n1. Open up the Info.plist **in Xcode** (right-click > Open As > Property List)\r\n2. Next to \"Information Property List\" click on the tiny `+` button.\r\n3. Under `key`, type \"Privacy - Camera Usage Description\"\r\n4. Under `value`, type \"To be able to scan barcodes\"\r\n\r\n_NOTE:_ \"To be able to scan barcodes\" can be substituted for anything you like.\r\n\r\nMore info here: https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription\r\n\r\n### Android\r\n\r\nWithin your `AndroidManifest.xml` file, change the following:\r\n\r\n```diff\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<manifest\r\n  xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n+  xmlns:tools=\"http://schemas.android.com/tools\"\r\n  package=\"com.example\">\r\n\r\n  <application\r\n+    android:hardwareAccelerated=\"true\"\r\n  >\r\n  </application>\r\n\r\n+  <uses-permission android:name=\"android.permission.CAMERA\" />\r\n\r\n+  <uses-sdk tools:overrideLibrary=\"com.google.zxing.client.android\" />\r\n</manifest>\r\n```\r\n\r\n## Usage\r\n\r\nThe complete API reference can be found [here](./API_REFERENCE.md).\r\n\r\nScanning a (QR) barcode can be as simple as:\r\n\r\n```js\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nconst startScan = async () => {\r\n  BarcodeScanner.hideBackground(); // make background of WebView transparent\r\n\r\n  const result = await BarcodeScanner.startScan(); // start scanning and wait for a result\r\n\r\n  // if the result has content\r\n  if (result.hasContent) {\r\n    console.log(result.content); // log the raw scanned content\r\n  }\r\n};\r\n```\r\n\r\n### Opacity of the WebView\r\n\r\nBecause of the fact that the Scanner View will be rendered behind the WebView, you will have to call `hideBackground()` to make the WebView and the `<html>` element transparent. Every other element that needs transparency, you will have to handle yourself.\r\n\r\nThe `<html>` element is made transparent by adding `background: 'transparent';` to the `style=\"\"` attribute. So in theory it is possible that this is overwritten by some CSS property in your setup. Because this plugin does not aim to fix every single scenario out there, you will have to think of a workaround for this yourself, if this applies to you (probably not).\r\n\r\nIf you still cannot see the camera view, check if any other elements are blocking it. For more info on this see [here](#the-scanner-view-does-not-show-up).\r\n\r\n### Stopping a scan\r\n\r\nAfter `startScan()` is resolved, the Scanner View will be automatically destroyed to save battery. But if you want to cancel the scan before `startScan()` is resolved (AKA no code has been recognized yet), you will have to call `stopScan()` manually. Example:\r\n\r\n```js\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nconst stopScan = () => {\r\n  BarcodeScanner.showBackground();\r\n  BarcodeScanner.stopScan();\r\n};\r\n```\r\n\r\nIt is also important to think about cases where a users hits some sort of a back button (either hardware or software). It is advised to call `stopScan()` in these types of situations as well.\r\n\r\nIn Vue.js you could do something like this in a specific view where you use the scanner:\r\n\r\n```vue\r\n<script>\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nexport default {\r\n  methods: {\r\n    stopScan() {\r\n      BarcodeScanner.showBackground();\r\n      BarcodeScanner.stopScan();\r\n    },\r\n  },\r\n\r\n  deactivated() {\r\n    this.stopScan();\r\n  },\r\n\r\n  beforeDestroy() {\r\n    this.stopScan();\r\n  },\r\n};\r\n</script>\r\n```\r\n\r\n### Preparing a scan\r\n\r\nTo boost performance and responsiveness (by just a bit), a `prepare()` method is available. If you know your script will call `startScan()` sometime very soon, you can call `prepare()` to make `startScan()` work even faster.\r\n\r\nFor example:\r\n\r\n```js\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nconst prepare = () => {\r\n  BarcodeScanner.prepare();\r\n};\r\n\r\nconst startScan = async () => {\r\n  BarcodeScanner.hideBackground();\r\n  const result = await BarcodeScanner.startScan();\r\n  if (result.hasContent) {\r\n    console.log(result.content);\r\n  }\r\n};\r\n\r\nconst stopScan = () => {\r\n  BarcodeScanner.showBackground();\r\n  BarcodeScanner.stopScan();\r\n};\r\n\r\nconst askUser = () => {\r\n  prepare();\r\n\r\n  const c = confirm('Do you want to scan a barcode?');\r\n\r\n  if (c) {\r\n    startScan();\r\n  } else {\r\n    stopScan();\r\n  }\r\n};\r\n\r\naskUser();\r\n```\r\n\r\nThis is fully optional and would work the same as:\r\n\r\n```js\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nconst startScan = async () => {\r\n  BarcodeScanner.hideBackground();\r\n  const result = await BarcodeScanner.startScan();\r\n  if (result.hasContent) {\r\n    console.log(result.content);\r\n  }\r\n};\r\n\r\nconst askUser = () => {\r\n  const c = confirm('Do you want to scan a barcode?');\r\n\r\n  if (c) {\r\n    startScan();\r\n  }\r\n};\r\n\r\naskUser();\r\n```\r\n\r\nThe latter will just appear a little slower to the user.\r\n\r\n### Permissions\r\n\r\nThis plugin does not automatically handle permissions. But the plugin _does_ have a utility method to check and request the permission. You will have to request the permission from JavaScript. A simple example follows:\r\n\r\n```js\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nconst checkPermission = async () => {\r\n  // check or request permission\r\n  const status = await BarcodeScanner.checkPermission({ force: true });\r\n\r\n  if (status.granted) {\r\n    // the user granted permission\r\n    return true;\r\n  }\r\n\r\n  return false;\r\n};\r\n```\r\n\r\nA more detailed and more UX-optimized example:\r\n\r\n```js\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nconst didUserGrantPermission = async () => {\r\n  // check if user already granted permission\r\n  const status = await BarcodeScanner.checkPermission({ force: false });\r\n\r\n  if (status.granted) {\r\n    // user granted permission\r\n    return true;\r\n  }\r\n\r\n  if (status.denied) {\r\n    // user denied permission\r\n    return false;\r\n  }\r\n\r\n  if (status.asked) {\r\n    // system requested the user for permission during this call\r\n    // only possible when force set to true\r\n  }\r\n\r\n  if (status.neverAsked) {\r\n    // user has not been requested this permission before\r\n    // it is advised to show the user some sort of prompt\r\n    // this way you will not waste your only chance to ask for the permission\r\n    const c = confirm(\r\n      'We need your permission to use your camera to be able to scan barcodes',\r\n    );\r\n    if (!c) {\r\n      return false;\r\n    }\r\n  }\r\n\r\n  if (status.restricted || status.unknown) {\r\n    // ios only\r\n    // probably means the permission has been denied\r\n    return false;\r\n  }\r\n\r\n  // user has not denied permission\r\n  // but the user also has not yet granted the permission\r\n  // so request it\r\n  const statusRequest = await BarcodeScanner.checkPermission({ force: true });\r\n\r\n  if (statusRequest.asked) {\r\n    // system requested the user for permission during this call\r\n    // only possible when force set to true\r\n  }\r\n\r\n  if (statusRequest.granted) {\r\n    // the user did grant the permission now\r\n    return true;\r\n  }\r\n\r\n  // user did not grant the permission, so he must have declined the request\r\n  return false;\r\n};\r\n\r\ndidUserGrantPermission();\r\n```\r\n\r\nIf a user denied the permission for good, `status.denied` will be set to true. On Android this will happen only when the user checks the box `never ask again`. To get the permission anyway you will have to redirect the user to the settings of the app. This can be done simply be doing the following:\r\n\r\n```js\r\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\r\n\r\nconst checkPermission = async () => {\r\n  const status = await BarcodeScanner.checkPermission();\r\n\r\n  if (status.denied) {\r\n    // the user denied permission for good\r\n    // redirect user to app settings if they want to grant it anyway\r\n    const c = confirm(\r\n      'If you want to grant permission for using your camera, enable it in the app settings.',\r\n    );\r\n    if (c) {\r\n      BarcodeScanner.openAppSettings();\r\n    }\r\n  }\r\n};\r\n```\r\n\r\n### Target only specific barcodes\r\n\r\nYou can setup the scanner to only recognize specific types of barcodes like this:\r\n\r\n```ts\r\nimport {\r\n  BarcodeScanner,\r\n  SupportedFormat,\r\n} from '@capacitor-community/barcode-scanner';\r\n\r\nBarcodeScanner.startScan({ targetedFormats: [SupportedFormat.QR_CODE] }); // this will now only target QR-codes\r\n```\r\n\r\nIf `targetedFormats` is _not specified_ or _left empty_, _all types_ of barcodes will be targeted.\r\n\r\nTargeting only specific types can have the following benefits:\r\n\r\n- Improved performance (since the decoder only has to look for the specified barcodes)\r\n- Improved User Experience (since scanning a barcode that is not supported by your case, will not work)\r\n\r\nThe following types are supported:\r\n\r\n<table>\r\n  <thead>\r\n    <tr>\r\n      <th>Category</th>\r\n      <th>Type</th>\r\n      <th>Android</th>\r\n      <th>iOS</th>\r\n    </tr>\r\n  </thead>\r\n  <tbody>\r\n    <tr>\r\n      <td rowspan=\"6\">1D Product</td>\r\n    </tr>\r\n    <tr>\r\n      <td>UPC_A</td>\r\n      <td>✔</td>\r\n      <td>✔**</td>\r\n    </tr>\r\n    <tr>\r\n      <td>UPC_E</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>UPC_EAN_EXTENSION</td>\r\n      <td>✔</td>\r\n      <td>✖</td>\r\n    </tr>\r\n    <tr>\r\n      <td>EAN_8</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>EAN_13</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td rowspan=\"8\">1D Industrial</td>\r\n    </tr>\r\n    <tr>\r\n      <td>CODE_39</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>CODE_39_MOD_43</td>\r\n      <td>✖</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>CODE_93</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>CODE_128</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>CODABAR</td>\r\n      <td>✔</td>\r\n      <td>✖</td>\r\n    </tr>\r\n    <tr>\r\n      <td>ITF</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>ITF_14</td>\r\n      <td>✖</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td rowspan=\"8\">2D</td>\r\n    </tr>\r\n    <tr>\r\n      <td>AZTEC</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>DATA_MATRIX</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>MAXICODE</td>\r\n      <td>✔</td>\r\n      <td>✖</td>\r\n    </tr>\r\n    <tr>\r\n      <td>PDF_417</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>QR_CODE</td>\r\n      <td>✔</td>\r\n      <td>✔</td>\r\n    </tr>\r\n    <tr>\r\n      <td>RSS_14</td>\r\n      <td>✔</td>\r\n      <td>✖</td>\r\n    </tr>\r\n    <tr>\r\n      <td>RSS_EXPANDED</td>\r\n      <td>✔</td>\r\n      <td>✖</td>\r\n    </tr>\r\n  </tbody>\r\n</table>\r\n\r\n\\*\\* `UPC_A` is supported on iOS, but according to the offical [Apple docs](https://developer.apple.com/documentation/avfoundation/avmetadataobject/objecttype/1618807-ean13) it is part of `EAN_13`. So you should specify `EAN_13` to be able to scan this. If you want to distinguish them from one another, you should manually do so after getting the result.\r\n\r\n## Troubleshooting\r\n\r\n### I have a `Error: Plugin BarcodeScanner does not respond to method call` error message on iOS\r\n\r\nIn Xcode click on `Product` > `Clean Build Folder` and try to build again.\r\n\r\n### I have a `Cannot resolve symbol BarcodeScanner` error message in Android Studio\r\n\r\nIn Android Studio click `File` > `Sync Project with Gradle Files` and try to build again.\r\n\r\n### The scanner view does not show up\r\n\r\nFirst check that the camera permission is granted. If the scanner view does still not appear it is likely that some UI element is blocking it. Check out these issues for more information on how to resolve such an issue: [#7](https://github.com/capacitor-community/barcode-scanner/issues/7#issuecomment-744441148) and [#26](https://github.com/capacitor-community/barcode-scanner/issues/26)\r\n\r\n## TODO\r\n\r\nA non-exhaustive list of todos:\r\n\r\n- Support for switching between cameras\r\n- Support for toggling the flashlight\r\n- Support for web\r\n","readmeFilename":"README.md"}