{"id":4567,"url":"https://github.com/ideacreation/react-native-barcodescanner","last_synced_at":"2025-08-04T01:32:40.642Z","repository":{"id":52910242,"uuid":"43756339","full_name":"ideacreation/react-native-barcodescanner","owner":"ideacreation","description":"A barcode scanner component for react native - not maintained anymore - use react-native-camera","archived":false,"fork":false,"pushed_at":"2018-09-17T14:50:04.000Z","size":402,"stargazers_count":538,"open_issues_count":61,"forks_count":160,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-08T23:42:23.720Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ideacreation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-06T14:34:37.000Z","updated_at":"2024-08-25T19:27:35.000Z","dependencies_parsed_at":"2022-08-23T11:10:22.605Z","dependency_job_id":null,"html_url":"https://github.com/ideacreation/react-native-barcodescanner","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideacreation%2Freact-native-barcodescanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideacreation%2Freact-native-barcodescanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideacreation%2Freact-native-barcodescanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ideacreation%2Freact-native-barcodescanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ideacreation","download_url":"https://codeload.github.com/ideacreation/react-native-barcodescanner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582488,"owners_count":17940587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:16.488Z","updated_at":"2024-12-07T08:30:43.443Z","avatar_url":"https://github.com/ideacreation.png","language":"Java","funding_links":[],"categories":["Components","Java","Libraries","组件"],"sub_categories":["System","系统相关"],"readme":"# react-native-barcodescanner - not maintained anymore - use react-native-camera\n\nVersion 0.4.0 of [react-native-camera](https://github.com/lwansbrough/react-native-camera) includes barcode scanning for android as well. I recommend using it for barcode and QR scanning as you can use the same library both for iOS and android and the implementation is more robust than this one.\n\n## Old README\n\nA barcode scanner component for react native android. The library uses https://github.com/zxing/zxing to decode the barcodes.\n\n### React Native dependencies\n\n- Version 0.1.4 for React Native \u003c=0.18\n- Version 1.x.x for React Native \u003e=0.19\n- Version 3.x.x for React Native \u003e=0.25\n\n### Installation\n\n```bash\nnpm i --save react-native-barcodescanner\n```\n\n### Link it to your android project\n\nYou can link it simply by running `react-native link`.\n\n#### Manual linking\n\n* In `android/settings.gradle`\n\n  ```gradle\n  ...\n  include ':react-native-barcodescanner', ':app'\n  project(':react-native-barcodescanner').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-barcodescanner/android')\n  ```\n\n* In `android/app/build.gradle`\n\n  ```gradle\n  ...\n  dependencies {\n      ...\n      compile project(':react-native-barcodescanner')\n  }\n  ```\n\n* register module (in MainApplication.java)\n\n  Add the following **import** statement:\n  ```Java\n  import com.eguma.barcodescanner.BarcodeScannerPackage;\n  ```\n\n  ...and then add `BarcodeScannerPackage` to exported package list *(MainApplication.java#getPackages)*:\n\n  ```Java\n  public class MainApplication extends Application implements ReactApplication {\n      // (...)\n\n      @Override\n      protected List\u003cReactPackage\u003e getPackages() {\n        return Arrays.\u003cReactPackage\u003easList(\n          new MainReactPackage(),\n          new BarcodeScannerPackage()\n        );\n      }\n  }\n  ```\n\n## Usage\n\n```javascript\nimport React, {\n  AppRegistry,\n  Component,\n} from 'react-native';\nimport BarcodeScanner from 'react-native-barcodescanner';\n\nclass BarcodeScannerApp extends Component {\n  constructor(props) {\n    super(props);\n\n    this.state = {\n      torchMode: 'off',\n      cameraType: 'back',\n    };\n  }\n\n  barcodeReceived(e) {\n    console.log('Barcode: ' + e.data);\n    console.log('Type: ' + e.type);\n  }\n\n  render() {\n    return (\n      \u003cBarcodeScanner\n        onBarCodeRead={this.barcodeReceived}\n        style={{ flex: 1 }}\n        torchMode={this.state.torchMode}\n        cameraType={this.state.cameraType}\n      /\u003e\n    );\n  }\n}\n\nAppRegistry.registerComponent('BarcodeScannerApp', () =\u003e BarcodeScannerApp);\n```\n\n## Example\n\nTry the included [BarcodeScanner example](https://github.com/ideacreation/react-native-barcodescanner/tree/master/Examples/BarcodeScanner) yourself:\n\n```sh\ngit clone git@github.com:ideacreation/react-native-barcodescanner.git\ncd react-native-barcodescanner/Examples/BarcodeScanner\nnpm install\nreact-native run-android\n\n```\n\nTo test the example you can scan the barcodes in the [Testcodes.pdf](https://github.com/ideacreation/react-native-barcodescanner/tree/master/Examples/Testcodes.pdf) file.\n\n## Properties\n\n#### `onBarCodeRead`\n\nWill call the specified method when a barcode is detected in the camera's view.\nEvent contains `data` (barcode value) and `type` (barcode type).\nThe following barcode types can be recognised:\n\n```java\nBarcodeFormat.UPC_A\nBarcodeFormat.UPC_E\nBarcodeFormat.EAN_13\nBarcodeFormat.EAN_8\nBarcodeFormat.RSS_14\nBarcodeFormat.CODE_39\nBarcodeFormat.CODE_93\nBarcodeFormat.CODE_128\nBarcodeFormat.ITF\nBarcodeFormat.CODABAR\nBarcodeFormat.QR_CODE\nBarcodeFormat.DATA_MATRIX\nBarcodeFormat.PDF_417\n```\n\n#### `torchMode`\n\nValues:\n`on`,\n`off` (default)\n\nUse the `torchMode` property to specify the camera torch mode.\n\n#### `cameraType`\n\nValues:\n`back` (default),\n`front`\n\nUse the `cameraType` property to specify the camera to use. If you specify the front camera, but the device has no front camera the back camera is used.\n\n### Viewfinder\n\nThe viewfinder is a child react component of the barcodescanner component. if you don't need the viewfinder (e.g. because you want your own child components to render) or you want your own viewfinder you can disable it with `showViewFinder={false}`.\n\nThe following properties can be used to style the viewfinder:\n\n`viewFinderBackgroundColor`,\n`viewFinderBorderColor`,\n`viewFinderBorderWidth`,\n`viewFinderBorderLength`,\n`viewFinderShowLoadingIndicator`,\n`viewFinderHeight`,\n`viewFinderWidth`,\n\nAll color values are strings (e.g. '#eee' or 'rgba(0, 0, 0, 0.3)', default: 'white'). `viewFinderHeight` (default: 200), `viewFinderWidth` (default: 200), `viewFinderBorderWidth` (default: 2) and `viewFinderBorderLength` (default: 30) are numbers, `viewFinderShowLoadingIndicator` is either `true` or `false` (default) and shows a ActivityIndicator centered in the viewfinder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fideacreation%2Freact-native-barcodescanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fideacreation%2Freact-native-barcodescanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fideacreation%2Freact-native-barcodescanner/lists"}