{"_id":"@asensei/barcode-scanner","_rev":"5-089c4335d16a37f767a5e00aa87af8f7","name":"@asensei/barcode-scanner","dist-tags":{"latest":"5.0.2"},"versions":{"5.0.0":{"name":"@asensei/barcode-scanner","version":"5.0.0","keywords":["capacitor","plugin","native"],"author":{"name":"tafelnl"},"license":"MIT","_id":"@asensei/barcode-scanner@5.0.0","maintainers":[{"name":"valerio.mazzeo.asensei","email":"valerio.mazzeo@asensei.com"},{"name":"daraghmccarthy","email":"daragh.mccarthy@asensei.com"},{"name":"rossarnott","email":"ross.arnott@asensei.com"},{"name":"billbu","email":"bill.burgar@asensei.com"},{"name":"udamaster","email":"stacy@youngholdings.ca"},{"name":"duncancameron","email":"duncan.cameron@asensei.com"},{"name":"kevinstraube","email":"kevin.straube@asensei.com"},{"name":"mikenurquhart","email":"mike.urquhart@asensei.com"},{"name":"basitasensei","email":"basit.kirmani@asensei.com"}],"homepage":"https://github.com/ASENSEI/barcode-scanner#readme","bugs":{"url":"https://github.com/ASENSEI/barcode-scanner/issues"},"dist":{"shasum":"3ca8fadb98fd50629fdad0775ab78a4f91e28acf","tarball":"https://registry.npmjs.org/@asensei/barcode-scanner/-/barcode-scanner-5.0.0.tgz","fileCount":28,"integrity":"sha512-a97bU+faoYdT2lmc3OF+eVZVwsrPTUVwbd/7uhfHeqCLBFGstAPkVHKv6knU5l9fU1hXGohqhWpZrQNJSm5rqg==","signatures":[{"sig":"MEQCICKHXH2VCXpuQgb/689xJ19MPL/EbayIyRIgn/PYMbaPAiBZUKC8eUUC2tHlmhD55Jr2g3X0RJcD9v37RMUvPt6fJQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":175858},"main":"dist/plugin.cjs.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","module":"dist/esm/index.js","gitHead":"6f2d3263dea4e10f96ef96998415e5af50e0e03f","scripts":{"lint":"npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint","build":"npm run clean && tsc && rollup -c rollup.config.js --bundleConfigAsCjs","clean":"rimraf ./dist","watch":"tsc --watch","docgen":"docgen --api BarcodeScannerPlugin --output-readme API_REFERENCE.md","eslint":"eslint . --ext ts","verify":"npm run verify:ios && npm run verify:android && npm run verify:web","prettier":"prettier \"**/*.{css,html,ts,js,java}\"","swiftlint":"node-swiftlint","verify:ios":"cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination \"platform=iOS Simulator,name=iPhone 12\" && cd ..","verify:web":"npm run build","prepublishOnly":"npm run build","verify:android":"cd android && ./gradlew clean build test && cd .."},"_npmUser":{"name":"udamaster","email":"stacy@youngholdings.ca"},"prettier":"@ionic/prettier-config","capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"swiftlint":"@ionic/swiftlint-config","repository":{"url":"git+https://github.com/ASENSEI/barcode-scanner.git","type":"git"},"_npmVersion":"10.2.3","description":"A fast and efficient (QR) barcode scanner for Capacitor","directories":{"example":"examples"},"_nodeVersion":"20.10.0","dependencies":{"@zxing/browser":"^0.1.3","@zxing/library":"^0.20.0"},"eslintConfig":{"extends":"@ionic/eslint-config/recommended","ignorePatterns":["dist/**/*"]},"_hasShrinkwrap":false,"devDependencies":{"husky":"^8.0.3","eslint":"^8.40.0","rimraf":"^5.0.0","rollup":"^3.21.5","prettier":"~2.8.8","swiftlint":"^1.0.2","typescript":"~5.0.4","pretty-quick":"^3.1.3","@capacitor/cli":"^7.0.0","@capacitor/ios":"^7.0.0","@capacitor/core":"^7.0.0","@capacitor/docgen":"0.2.1","@capacitor/android":"^7.0.0","@ionic/eslint-config":"^0.3.0","prettier-plugin-java":"~2.1.0","@ionic/prettier-config":"^3.0.0","@ionic/swiftlint-config":"^1.1.2"},"peerDependencies":{"@capacitor/core":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/barcode-scanner_5.0.0_1763061028700_0.7330520062118493","host":"s3://npm-registry-packages-npm-production"}},"5.0.1":{"name":"@asensei/barcode-scanner","version":"5.0.1","keywords":["capacitor","plugin","native"],"author":{"name":"tafelnl"},"license":"MIT","_id":"@asensei/barcode-scanner@5.0.1","maintainers":[{"name":"valerio.mazzeo.asensei","email":"valerio.mazzeo@asensei.com"},{"name":"daraghmccarthy","email":"daragh.mccarthy@asensei.com"},{"name":"rossarnott","email":"ross.arnott@asensei.com"},{"name":"billbu","email":"bill.burgar@asensei.com"},{"name":"udamaster","email":"stacy@youngholdings.ca"},{"name":"duncancameron","email":"duncan.cameron@asensei.com"},{"name":"kevinstraube","email":"kevin.straube@asensei.com"},{"name":"mikenurquhart","email":"mike.urquhart@asensei.com"},{"name":"basitasensei","email":"basit.kirmani@asensei.com"}],"homepage":"https://github.com/ASENSEI/barcode-scanner#readme","bugs":{"url":"https://github.com/ASENSEI/barcode-scanner/issues"},"dist":{"shasum":"4413184c3b1eddfb9ce8cc56042be2742a1b449e","tarball":"https://registry.npmjs.org/@asensei/barcode-scanner/-/barcode-scanner-5.0.1.tgz","fileCount":28,"integrity":"sha512-+wBdwr4RR0uAqlmZORamaATpI3Kk2MmJIOT2jDaVmsJhMlzHupDHInF3Wj8P3MdgJHGRmiW2kFPyHpAYHHBkHA==","signatures":[{"sig":"MEUCIQDl0Yjq+1ack9WVmh1K9PIFK9xa3IFnga/3C4YU+7rDJQIgfA7cynhT9Y4zfBEeukstlB/HSCdkEss1OHhykt7mq3k=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":175858},"main":"dist/plugin.cjs.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","module":"dist/esm/index.js","gitHead":"ad9a9124b4c083a1fbd9e4c6994542d926ba8597","scripts":{"lint":"npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint","build":"npm run clean && tsc && rollup -c rollup.config.js --bundleConfigAsCjs","clean":"rimraf ./dist","watch":"tsc --watch","docgen":"docgen --api BarcodeScannerPlugin --output-readme API_REFERENCE.md","eslint":"eslint . --ext ts","verify":"npm run verify:ios && npm run verify:android && npm run verify:web","prettier":"prettier \"**/*.{css,html,ts,js,java}\"","swiftlint":"node-swiftlint","verify:ios":"cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination \"platform=iOS Simulator,name=iPhone 12\" && cd ..","verify:web":"npm run build","prepublishOnly":"npm run build","verify:android":"cd android && ./gradlew clean build test && cd .."},"_npmUser":{"name":"udamaster","email":"stacy@youngholdings.ca"},"prettier":"@ionic/prettier-config","capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"swiftlint":"@ionic/swiftlint-config","repository":{"url":"git+https://github.com/ASENSEI/barcode-scanner.git","type":"git"},"_npmVersion":"10.2.3","description":"A fast and efficient (QR) barcode scanner for Capacitor","directories":{"example":"examples"},"_nodeVersion":"20.10.0","dependencies":{"@zxing/browser":"^0.1.3","@zxing/library":"^0.20.0"},"eslintConfig":{"extends":"@ionic/eslint-config/recommended","ignorePatterns":["dist/**/*"]},"_hasShrinkwrap":false,"devDependencies":{"husky":"^8.0.3","eslint":"^8.40.0","rimraf":"^5.0.0","rollup":"^3.21.5","prettier":"~2.8.8","swiftlint":"^1.0.2","typescript":"~5.0.4","pretty-quick":"^3.1.3","@capacitor/cli":"^7.0.0","@capacitor/ios":"^7.0.0","@capacitor/core":"^7.0.0","@capacitor/docgen":"0.2.1","@capacitor/android":"^7.0.0","@ionic/eslint-config":"^0.3.0","prettier-plugin-java":"~2.1.0","@ionic/prettier-config":"^3.0.0","@ionic/swiftlint-config":"^1.1.2"},"peerDependencies":{"@capacitor/core":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/barcode-scanner_5.0.1_1763062872071_0.41188694770563106","host":"s3://npm-registry-packages-npm-production"}},"5.0.2":{"name":"@asensei/barcode-scanner","version":"5.0.2","keywords":["capacitor","plugin","native"],"author":{"name":"tafelnl"},"license":"MIT","_id":"@asensei/barcode-scanner@5.0.2","maintainers":[{"name":"valerio.mazzeo.asensei","email":"valerio.mazzeo@asensei.com"},{"name":"daraghmccarthy","email":"daragh.mccarthy@asensei.com"},{"name":"rossarnott","email":"ross.arnott@asensei.com"},{"name":"billbu","email":"bill.burgar@asensei.com"},{"name":"udamaster","email":"stacy@youngholdings.ca"},{"name":"duncancameron","email":"duncan.cameron@asensei.com"},{"name":"kevinstraube","email":"kevin.straube@asensei.com"},{"name":"mikenurquhart","email":"mike.urquhart@asensei.com"},{"name":"basitasensei","email":"basit.kirmani@asensei.com"}],"homepage":"https://github.com/ASENSEI/barcode-scanner#readme","bugs":{"url":"https://github.com/ASENSEI/barcode-scanner/issues"},"dist":{"shasum":"814ce4333867c9fdfab564078dfc085fc3581911","tarball":"https://registry.npmjs.org/@asensei/barcode-scanner/-/barcode-scanner-5.0.2.tgz","fileCount":28,"integrity":"sha512-HV5LHqjMl9smK7+K+rj/8Yf5cXsULr4orlDWZi12oJ8I3Q6lBru18QiCoo6jnmsi+yPHppQe69TYzt28m07mCA==","signatures":[{"sig":"MEUCIQDy9zXzwvzm/BmH7Cy+z5QYGXxQ55Vg0Rn0EJobk582FAIgQ9VJU+Al62DJjWYkg2Zysgm1QVZa2Idp27UUlYuDAlY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":175836},"main":"dist/plugin.cjs.js","types":"dist/esm/index.d.ts","unpkg":"dist/plugin.js","module":"dist/esm/index.js","gitHead":"ce0d140388afbc19f5347082d5914fbd0ea4c7f7","scripts":{"lint":"npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint","build":"npm run clean && tsc && rollup -c rollup.config.js --bundleConfigAsCjs","clean":"rimraf ./dist","watch":"tsc --watch","docgen":"docgen --api BarcodeScannerPlugin --output-readme API_REFERENCE.md","eslint":"eslint . --ext ts","verify":"npm run verify:ios && npm run verify:android && npm run verify:web","prettier":"prettier \"**/*.{css,html,ts,js,java}\"","swiftlint":"node-swiftlint","verify:ios":"cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination \"platform=iOS Simulator,name=iPhone 12\" && cd ..","verify:web":"npm run build","prepublishOnly":"npm run build","verify:android":"cd android && ./gradlew clean build test && cd .."},"_npmUser":{"name":"udamaster","email":"stacy@youngholdings.ca"},"prettier":"@ionic/prettier-config","capacitor":{"ios":{"src":"ios"},"android":{"src":"android"}},"swiftlint":"@ionic/swiftlint-config","repository":{"url":"git+https://github.com/ASENSEI/barcode-scanner.git","type":"git"},"_npmVersion":"10.2.3","description":"A fast and efficient (QR) barcode scanner for Capacitor","directories":{"example":"examples"},"_nodeVersion":"20.10.0","dependencies":{"@zxing/browser":"^0.1.3","@zxing/library":"^0.20.0"},"eslintConfig":{"extends":"@ionic/eslint-config/recommended","ignorePatterns":["dist/**/*"]},"_hasShrinkwrap":false,"devDependencies":{"husky":"^8.0.3","eslint":"^8.40.0","rimraf":"^5.0.0","rollup":"^3.21.5","prettier":"~2.8.8","swiftlint":"^1.0.2","typescript":"~5.0.4","pretty-quick":"^3.1.3","@capacitor/cli":"^7.0.0","@capacitor/ios":"^7.0.0","@capacitor/core":"^7.0.0","@capacitor/docgen":"0.2.1","@capacitor/android":"^7.0.0","@ionic/eslint-config":"^0.3.0","prettier-plugin-java":"~2.1.0","@ionic/prettier-config":"^3.0.0","@ionic/swiftlint-config":"^1.1.2"},"peerDependencies":{"@capacitor/core":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/barcode-scanner_5.0.2_1763069075474_0.695742336620301","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-11-13T19:10:28.631Z","modified":"2026-07-01T08:58:50.071Z","5.0.0":"2025-11-13T19:10:28.916Z","5.0.1":"2025-11-13T19:41:12.298Z","5.0.2":"2025-11-13T21:24:35.675Z"},"bugs":{"url":"https://github.com/ASENSEI/barcode-scanner/issues"},"author":{"name":"tafelnl"},"license":"MIT","homepage":"https://github.com/ASENSEI/barcode-scanner#readme","keywords":["capacitor","plugin","native"],"repository":{"url":"git+https://github.com/ASENSEI/barcode-scanner.git","type":"git"},"description":"A fast and efficient (QR) barcode scanner for Capacitor","maintainers":[{"email":"ross.arnott@asensei.com","name":"rossarnott"},{"email":"bill.burgar@asensei.com","name":"billbu"},{"email":"stacy@youngholdings.ca","name":"udamaster"},{"email":"duncan.cameron@asensei.com","name":"duncancameron"},{"email":"kevin.straube@asensei.com","name":"kevinstraube"},{"email":"mike.urquhart@asensei.com","name":"mikenurquhart"},{"email":"mautisim.munir@asensei.com","name":"mautisim"}],"readme":"# DEPRECATED\n\nThis package is deprecated in favor of [`@capacitor/barcode-scanner`](https://github.com/ionic-team/capacitor-barcode-scanner).\n\n\n<p align=\"center\"><br><img src=\"https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png\" width=\"128\" height=\"128\" /></p>\n<h3 align=\"center\">Barcode Scanner</h3>\n<p align=\"center\"><strong><code>@capacitor-community/barcode-scanner</code></strong></p>\n<p align=\"center\">\n  A fast and efficient (QR) barcode scanner for Capacitor.\n</p>\n\n<p align=\"center\">\n  <img src=\"https://img.shields.io/maintenance/no/2023?style=flat-square\" />\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>\n<br>\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>\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>\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n<a href=\"#contributors-\"><img src=\"https://img.shields.io/badge/all%20contributors-1-orange?style=flat-square\" /></a>\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n</p>\n\n## Table of Contents\n\n- [Maintainers](#maintainers)\n- [About](#about)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Troubleshooting](#troubleshooting)\n\n## Maintainers\n\n| Maintainer | GitHub                                | Active |\n| ---------- | ------------------------------------- | ------ |\n| thegnuu    | [thegnuu](https://github.com/thegnuu) | no     |\n| tafelnl    | [tafelnl](https://github.com/tafelnl) | no     |\n\n## About\n\n### Supported barcodes\n\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.\n\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.\n\nOn **Web** this library uses [`zxing/browser`](https://github.com/zxing-js/browser). That means **[this list of barcodes](https://github.com/zxing/zxing/#supported-formats)** is supported. The web implementation is currently in development, there might be issues and not all features are currently supported!\n\n### Note on supported Capacitor versions\n\n`v5.x.x-beta.x` pre-release based on ML-Kit that supports Capacitor `v5.x`\n\n`v4.x` supports Capacitor `v5.x`\n\n`v3.x` supports Capacitor `v4.x`\n\n`v2.x` supports Capacitor `v3.x`\n\n`v1.x` supports Capacitor `v2.x`\n\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)\n\n## Installation\n\n```bash\nnpm install @capacitor-community/barcode-scanner\nnpx cap sync\n```\n\n### iOS\n\nFor iOS you need to set a usage description in your info.plist file.\n\nThis can be done by either adding it to the Source Code directly or by using Xcode Property List inspector.\n\n**Adding it to the source code directly**\n\n1. Open up the Info.plist (in Xcode right-click > Open As > Source Code)\n2. With `<dict></dict>` change the following\n\n```diff\n<dict>\n+  <key>NSCameraUsageDescription</key>\n+  <string>To be able to scan barcodes</string>\n</dict>\n```\n\n_NOTE:_ \"To be able to scan barcodes\" can be substituted for anything you like.\n\n**Adding it by using Xcode Property List inspector**\n\n1. Open up the Info.plist **in Xcode** (right-click > Open As > Property List)\n2. Next to \"Information Property List\" click on the tiny `+` button.\n3. Under `key`, type \"Privacy - Camera Usage Description\"\n4. Under `value`, type \"To be able to scan barcodes\"\n\n_NOTE:_ \"To be able to scan barcodes\" can be substituted for anything you like.\n\nMore info here: https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription\n\n### Android\n\nWithin your `AndroidManifest.xml` file, change the following:\n\n```diff\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n  xmlns:android=\"http://schemas.android.com/apk/res/android\"\n+  xmlns:tools=\"http://schemas.android.com/tools\"\n  package=\"com.example\">\n\n  <application\n+    android:hardwareAccelerated=\"true\"\n  >\n  </application>\n\n+  <uses-permission android:name=\"android.permission.CAMERA\" />\n\n+  <uses-sdk tools:overrideLibrary=\"com.google.zxing.client.android\" />\n</manifest>\n```\n\n## Usage\n\nThe complete API reference can be found [here](./src/definitions.ts).\n\nScanning a (QR) barcode can be as simple as:\n\n```js\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nconst startScan = async () => {\n  // Check camera permission\n  // This is just a simple example, check out the better checks below\n  await BarcodeScanner.checkPermission({ force: true });\n\n  // make background of WebView transparent\n  // note: if you are using ionic this might not be enough, check below\n  BarcodeScanner.hideBackground();\n\n  const result = await BarcodeScanner.startScan(); // start scanning and wait for a result\n\n  // if the result has content\n  if (result.hasContent) {\n    console.log(result.content); // log the raw scanned content\n  }\n};\n```\n\n### Opacity of the WebView\n\n`hideBackground()` will make the `<html>` element transparent by adding `background: 'transparent';` to the `style` attribute.\n\nIf you are using Ionic you need to set some css variables as well, check [**here**](#ionic-css-variables)\n\nIf you still cannot see the camera view, check [**here**](#the-scanner-view-does-not-show-up)\n\n### Stopping a scan\n\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:\n\n```js\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nconst stopScan = () => {\n  BarcodeScanner.showBackground();\n  BarcodeScanner.stopScan();\n};\n```\n\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.\n\nIn Vue.js you could do something like this in a specific view where you use the scanner:\n\n```vue\n<script>\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nexport default {\n  methods: {\n    stopScan() {\n      BarcodeScanner.showBackground();\n      BarcodeScanner.stopScan();\n    },\n  },\n\n  deactivated() {\n    this.stopScan();\n  },\n\n  beforeDestroy() {\n    this.stopScan();\n  },\n};\n</script>\n```\n\n### Preparing a scan\n\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.\n\nFor example:\n\n```js\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nconst prepare = () => {\n  BarcodeScanner.prepare();\n};\n\nconst startScan = async () => {\n  BarcodeScanner.hideBackground();\n  const result = await BarcodeScanner.startScan();\n  if (result.hasContent) {\n    console.log(result.content);\n  }\n};\n\nconst stopScan = () => {\n  BarcodeScanner.showBackground();\n  BarcodeScanner.stopScan();\n};\n\nconst askUser = () => {\n  prepare();\n\n  const c = confirm('Do you want to scan a barcode?');\n\n  if (c) {\n    startScan();\n  } else {\n    stopScan();\n  }\n};\n\naskUser();\n```\n\nThis is fully optional and would work the same as:\n\n```js\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nconst startScan = async () => {\n  BarcodeScanner.hideBackground();\n  const result = await BarcodeScanner.startScan();\n  if (result.hasContent) {\n    console.log(result.content);\n  }\n};\n\nconst askUser = () => {\n  const c = confirm('Do you want to scan a barcode?');\n\n  if (c) {\n    startScan();\n  }\n};\n\naskUser();\n```\n\nThe latter will just appear a little slower to the user.\n\n### Permissions\n\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:\n\n```js\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nconst checkPermission = async () => {\n  // check or request permission\n  const status = await BarcodeScanner.checkPermission({ force: true });\n\n  if (status.granted) {\n    // the user granted permission\n    return true;\n  }\n\n  return false;\n};\n```\n\nA more detailed and more UX-optimized example:\n\n```js\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nconst didUserGrantPermission = async () => {\n  // check if user already granted permission\n  const status = await BarcodeScanner.checkPermission({ force: false });\n\n  if (status.granted) {\n    // user granted permission\n    return true;\n  }\n\n  if (status.denied) {\n    // user denied permission\n    return false;\n  }\n\n  if (status.asked) {\n    // system requested the user for permission during this call\n    // only possible when force set to true\n  }\n\n  if (status.neverAsked) {\n    // user has not been requested this permission before\n    // it is advised to show the user some sort of prompt\n    // this way you will not waste your only chance to ask for the permission\n    const c = confirm('We need your permission to use your camera to be able to scan barcodes');\n    if (!c) {\n      return false;\n    }\n  }\n\n  if (status.restricted || status.unknown) {\n    // ios only\n    // probably means the permission has been denied\n    return false;\n  }\n\n  // user has not denied permission\n  // but the user also has not yet granted the permission\n  // so request it\n  const statusRequest = await BarcodeScanner.checkPermission({ force: true });\n\n  if (statusRequest.asked) {\n    // system requested the user for permission during this call\n    // only possible when force set to true\n  }\n\n  if (statusRequest.granted) {\n    // the user did grant the permission now\n    return true;\n  }\n\n  // user did not grant the permission, so he must have declined the request\n  return false;\n};\n\ndidUserGrantPermission();\n```\n\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:\n\n```js\nimport { BarcodeScanner } from '@capacitor-community/barcode-scanner';\n\nconst checkPermission = async () => {\n  const status = await BarcodeScanner.checkPermission();\n\n  if (status.denied) {\n    // the user denied permission for good\n    // redirect user to app settings if they want to grant it anyway\n    const c = confirm('If you want to grant permission for using your camera, enable it in the app settings.');\n    if (c) {\n      BarcodeScanner.openAppSettings();\n    }\n  }\n};\n```\n\n### Target only specific barcodes\n\nYou can setup the scanner to only recognize specific types of barcodes like this:\n\n```ts\nimport { BarcodeScanner, SupportedFormat } from '@capacitor-community/barcode-scanner';\n\nBarcodeScanner.startScan({ targetedFormats: [SupportedFormat.QR_CODE] }); // this will now only target QR-codes\n```\n\nIf `targetedFormats` is _not specified_ or _left empty_, _all types_ of barcodes will be targeted.\n\nTargeting only specific types can have the following benefits:\n\n- Improved performance (since the decoder only has to look for the specified barcodes)\n- Improved User Experience (since scanning a barcode that is not supported by your case, will not work)\n\nThe following types are supported:\n\n<table>\n  <thead>\n    <tr>\n      <th>Category</th>\n      <th>Type</th>\n      <th>Android</th>\n      <th>iOS</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td rowspan=\"6\">1D Product</td>\n    </tr>\n    <tr>\n      <td>UPC_A</td>\n      <td>✔</td>\n      <td>✔**</td>\n    </tr>\n    <tr>\n      <td>UPC_E</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>UPC_EAN_EXTENSION</td>\n      <td>✔</td>\n      <td>✖</td>\n    </tr>\n    <tr>\n      <td>EAN_8</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>EAN_13</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td rowspan=\"8\">1D Industrial</td>\n    </tr>\n    <tr>\n      <td>CODE_39</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>CODE_39_MOD_43</td>\n      <td>✖</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>CODE_93</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>CODE_128</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>CODABAR</td>\n      <td>✔</td>\n      <td>✖</td>\n    </tr>\n    <tr>\n      <td>ITF</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>ITF_14</td>\n      <td>✖</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td rowspan=\"8\">2D</td>\n    </tr>\n    <tr>\n      <td>AZTEC</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>DATA_MATRIX</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>MAXICODE</td>\n      <td>✔</td>\n      <td>✖</td>\n    </tr>\n    <tr>\n      <td>PDF_417</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>QR_CODE</td>\n      <td>✔</td>\n      <td>✔</td>\n    </tr>\n    <tr>\n      <td>RSS_14</td>\n      <td>✔</td>\n      <td>✖</td>\n    </tr>\n    <tr>\n      <td>RSS_EXPANDED</td>\n      <td>✔</td>\n      <td>✖</td>\n    </tr>\n  </tbody>\n</table>\n\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.\n\n## Troubleshooting\n\n### Ionic CSS variables\n\nIonic will add additional CSS variables which will prevent the scanner from showing up.\nTo fix this issue add the following snippet at the end of your global css.\n\n```css\nbody.scanner-active {\n  --background: transparent;\n  --ion-background-color: transparent;\n}\n```\n\nOnce this is done, you need to add this class to the body before using the scanner.\n\n```typescript\ndocument.querySelector('body').classList.add('scanner-active');\n```\n\nAfter your done with your scanning work, you can simply remove this class.\n\n```typescript\ndocument.querySelector('body').classList.remove('scanner-active');\n```\n\n### I have a `Error: Plugin BarcodeScanner does not respond to method call` error message on iOS\n\nIn Xcode click on `Product` > `Clean Build Folder` and try to build again.\n\n### I have a `Cannot resolve symbol BarcodeScanner` error message in Android Studio\n\nIn Android Studio click `File` > `Sync Project with Gradle Files` and try to build again.\n\n### The scanner view does not show up\n\nIf you cannot see the scanner in your viewport, please follow these steps:\n\n1. Check if camera permissions are granted properly\n2. Check if the scanner element does appear inside the DOM, somewhere within the `body` tag\n   - [It's not there](#i-do-not-find-the-scanner-in-the-dom)\n3. Check if some DOM elements are rendered on top of the scanner\n   - Search which element is causing the issue [#7](https://github.com/capacitor-community/barcode-scanner/issues/7#issuecomment-744441148)\n   - Play with javascript [#26](https://github.com/capacitor-community/barcode-scanner/issues/26)\n\n### I do not find the scanner in the DOM\n\nThis should appear in the DOM when running the `BarcodeScanner.startScan()` method.\n\n```html\n<body>\n  <!-- ... -->\n  <div style=\"position: absolute; left: 0px; top: -2px; height: 1px; overflow: hidden; visibility: hidden; width: 1px;\">\n    <span\n      style=\"position: absolute; font-size: 300px; width: auto; height: auto; margin: 0px; padding: 0px; font-family: Roboto, Arial, sans-serif;\"\n      >BESbswy</span\n    >\n  </div>\n  <!-- ... -->\n</body>\n```\n\nIf it does not, it may be a bug due to the component being loaded to deep inside the DOM tree.\nYou can try to see if the plugin is working properly by adding the following in your `app.component.ts` file.\n\n```typescript\nBarcodeScanner.hideBackground();\nconst result = await BarcodeScanner.startScan();\n```\n\n#### It doesn't appear\n\nIt could mean that you have missed a step by the [plugin configuration](#installation).\n\n#### I did the configuration correctly\n\nplease [open an issue](https://github.com/capacitor-community/barcode-scanner/issues/new/choose)\n\n## TODO\n\nA non-exhaustive list of todos:\n\n- Support for switching between cameras\n- Support for web\n","readmeFilename":"README.md"}